diff --git a/main.js b/main.js index ef23284d6ba6..1d134e0ea41e 100644 --- a/main.js +++ b/main.js @@ -1036,15 +1036,34 @@ app.on('ready', async () => { // We use this event only a single time to log the startup time of the app // from when it's first ready until the loading screen disappears. - ipc.once('signal-app-loaded', (event, { preloadTime }) => { + ipc.once('signal-app-loaded', (event, info) => { + const { preloadTime, connectTime, processedCount } = info; + const loadTime = Date.now() - startTime; const sqlInitTime = sqlInitTimeEnd - sqlInitTimeStart; + + const messageTime = loadTime - preloadTime - connectTime; + const messagesPerSec = (processedCount * 1000) / messageTime; + console.log('App loaded - time:', loadTime); console.log('SQL init - time:', sqlInitTime); console.log('Preload - time:', preloadTime); + console.log('WebSocket connect - time:', connectTime); + console.log('Processed count:', processedCount); + console.log('Messages per second:', messagesPerSec); if (enableCI) { - console._log('ci: app_loaded=%j', { loadTime, sqlInitTime, preloadTime }); + console._log( + 'ci: app_loaded=%s', + JSON.stringify({ + loadTime, + sqlInitTime, + preloadTime, + connectTime, + processedCount, + messagesPerSec, + }) + ); } }); diff --git a/preload.js b/preload.js index 476e367b59cf..cb07a93c3ef6 100644 --- a/preload.js +++ b/preload.js @@ -111,9 +111,19 @@ try { window.setBadgeCount = count => ipc.send('set-badge-count', count); - window.logAppLoadedEvent = () => + let connectStartTime = 0; + + window.logMessageReceiverConnect = () => { + if (connectStartTime === 0) { + connectStartTime = Date.now(); + } + }; + + window.logAppLoadedEvent = ({ processedCount }) => ipc.send('signal-app-loaded', { preloadTime: preloadEndTime - preloadStartTime, + connectTime: connectStartTime - preloadEndTime, + processedCount, }); // We never do these in our code, so we'll prevent it everywhere diff --git a/ts/background.ts b/ts/background.ts index 709a6cd34795..ed179087b5f7 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -2117,7 +2117,9 @@ export async function startApp(): Promise { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion view.onEmpty(); - window.logAppLoadedEvent(); + window.logAppLoadedEvent({ + processedCount: messageReceiver && messageReceiver.getProcessedCount(), + }); if (messageReceiver) { window.log.info( 'App loaded - messages:', diff --git a/ts/textsecure/MessageReceiver.ts b/ts/textsecure/MessageReceiver.ts index 7fbd16f11188..2c198c4898d2 100644 --- a/ts/textsecure/MessageReceiver.ts +++ b/ts/textsecure/MessageReceiver.ts @@ -332,6 +332,7 @@ class MessageReceiverInner extends EventTarget { onopen() { window.log.info('websocket open'); + window.logMessageReceiverConnect(); } onerror() { diff --git a/ts/window.d.ts b/ts/window.d.ts index 104327ebb40e..9097a632200c 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -545,7 +545,8 @@ declare global { hasSignalAccount: (number: string) => boolean; getServerTrustRoot: () => WhatIsThis; readyForUpdates: () => void; - logAppLoadedEvent: () => void; + logAppLoadedEvent: (options: { processedCount?: number }) => void; + logMessageReceiverConnect: () => void; // Runtime Flags isShowingModal?: boolean;