Report more performance stats

This commit is contained in:
Fedor Indutny 2021-04-13 16:43:56 -07:00 committed by GitHub
parent c6d5d852a9
commit a4ff7ae240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 5 deletions

23
main.js
View file

@ -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,
})
);
}
});

View file

@ -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

View file

@ -2117,7 +2117,9 @@ export async function startApp(): Promise<void> {
// 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:',

View file

@ -332,6 +332,7 @@ class MessageReceiverInner extends EventTarget {
onopen() {
window.log.info('websocket open');
window.logMessageReceiverConnect();
}
onerror() {

3
ts/window.d.ts vendored
View file

@ -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;