Report more performance stats
This commit is contained in:
parent
c6d5d852a9
commit
a4ff7ae240
5 changed files with 38 additions and 5 deletions
23
main.js
23
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
|
// 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.
|
// 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 loadTime = Date.now() - startTime;
|
||||||
const sqlInitTime = sqlInitTimeEnd - sqlInitTimeStart;
|
const sqlInitTime = sqlInitTimeEnd - sqlInitTimeStart;
|
||||||
|
|
||||||
|
const messageTime = loadTime - preloadTime - connectTime;
|
||||||
|
const messagesPerSec = (processedCount * 1000) / messageTime;
|
||||||
|
|
||||||
console.log('App loaded - time:', loadTime);
|
console.log('App loaded - time:', loadTime);
|
||||||
console.log('SQL init - time:', sqlInitTime);
|
console.log('SQL init - time:', sqlInitTime);
|
||||||
console.log('Preload - time:', preloadTime);
|
console.log('Preload - time:', preloadTime);
|
||||||
|
console.log('WebSocket connect - time:', connectTime);
|
||||||
|
console.log('Processed count:', processedCount);
|
||||||
|
console.log('Messages per second:', messagesPerSec);
|
||||||
|
|
||||||
if (enableCI) {
|
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,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
12
preload.js
12
preload.js
|
@ -111,9 +111,19 @@ try {
|
||||||
|
|
||||||
window.setBadgeCount = count => ipc.send('set-badge-count', count);
|
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', {
|
ipc.send('signal-app-loaded', {
|
||||||
preloadTime: preloadEndTime - preloadStartTime,
|
preloadTime: preloadEndTime - preloadStartTime,
|
||||||
|
connectTime: connectStartTime - preloadEndTime,
|
||||||
|
processedCount,
|
||||||
});
|
});
|
||||||
|
|
||||||
// We never do these in our code, so we'll prevent it everywhere
|
// We never do these in our code, so we'll prevent it everywhere
|
||||||
|
|
|
@ -2117,7 +2117,9 @@ export async function startApp(): Promise<void> {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
view.onEmpty();
|
view.onEmpty();
|
||||||
|
|
||||||
window.logAppLoadedEvent();
|
window.logAppLoadedEvent({
|
||||||
|
processedCount: messageReceiver && messageReceiver.getProcessedCount(),
|
||||||
|
});
|
||||||
if (messageReceiver) {
|
if (messageReceiver) {
|
||||||
window.log.info(
|
window.log.info(
|
||||||
'App loaded - messages:',
|
'App loaded - messages:',
|
||||||
|
|
|
@ -332,6 +332,7 @@ class MessageReceiverInner extends EventTarget {
|
||||||
|
|
||||||
onopen() {
|
onopen() {
|
||||||
window.log.info('websocket open');
|
window.log.info('websocket open');
|
||||||
|
window.logMessageReceiverConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
onerror() {
|
onerror() {
|
||||||
|
|
3
ts/window.d.ts
vendored
3
ts/window.d.ts
vendored
|
@ -545,7 +545,8 @@ declare global {
|
||||||
hasSignalAccount: (number: string) => boolean;
|
hasSignalAccount: (number: string) => boolean;
|
||||||
getServerTrustRoot: () => WhatIsThis;
|
getServerTrustRoot: () => WhatIsThis;
|
||||||
readyForUpdates: () => void;
|
readyForUpdates: () => void;
|
||||||
logAppLoadedEvent: () => void;
|
logAppLoadedEvent: (options: { processedCount?: number }) => void;
|
||||||
|
logMessageReceiverConnect: () => void;
|
||||||
|
|
||||||
// Runtime Flags
|
// Runtime Flags
|
||||||
isShowingModal?: boolean;
|
isShowingModal?: boolean;
|
||||||
|
|
Loading…
Reference in a new issue