Skip to content

Commit

Permalink
feat: profile main process (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack authored Oct 19, 2022
1 parent 0067da5 commit 72bd758
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 346 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@fontsource/montserrat": "^4.5.11",
"@palette.dev/electron": "^1.12.1",
"@palette.dev/electron": "^1.14.2",
"@palette.dev/webpack-plugin": "^1.2.0",
"axios": "^0.27.2",
"chart.js": "^3.8.2",
Expand Down
27 changes: 14 additions & 13 deletions app/release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "left-on-read",
"version": "2.0.3",
"author": "Left on Read",
"description": "A message analyzing platform",
"main": "./dist/main/main.js",
"scripts": {
"electron-rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
"postinstall": "yarn electron-rebuild && npm run link-modules",
"link-modules": "node -r ts-node/register ../../.erb/scripts/link-modules.ts"
},
"dependencies": {
"sqlite3": "^5.0.10"
}
"name": "left-on-read",
"version": "2.0.3",
"author": "Left on Read",
"description": "A message analyzing platform",
"main": "./dist/main/main.js",
"scripts": {
"electron-rebuild": "node -r ts-node/register ../../.erb/scripts/electron-rebuild.js",
"postinstall": "yarn electron-rebuild && npm run link-modules",
"link-modules": "node -r ts-node/register ../../.erb/scripts/link-modules.ts"
},
"dependencies": {
"sqlite3": "^5.0.10",
"v8-profiler-next": "1.6.0"
}
}
42 changes: 27 additions & 15 deletions app/release/app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==

"@mapbox/node-pre-gyp@^1.0.0":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz#09a8781a3a036151cdebbe8719d6f8b25d4058bc"
integrity sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==
version "1.0.10"
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz#8e6735ccebbb1581e5a7e652244cadc8a844d03c"
integrity sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==
dependencies:
detect-libc "^2.0.0"
https-proxy-agent "^5.0.0"
Expand Down Expand Up @@ -91,9 +91,9 @@ are-we-there-yet@^2.0.0:
readable-stream "^3.6.0"

are-we-there-yet@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-3.0.0.tgz#ba20bd6b553e31d62fc8c31bd23d22b95734390d"
integrity sha512-0GWpv50YSOcLXaN6/FAKY3vfRbllXWV2xvfA/oKJF8pzFhWXPV+yjhJXDBbjscDYowv7Yw1A3uigpzn5iEGTyw==
version "3.0.1"
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz#679df222b278c64f2cdba1175cdc00b0d96164bd"
integrity sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==
dependencies:
delegates "^1.0.0"
readable-stream "^3.6.0"
Expand Down Expand Up @@ -463,6 +463,11 @@ ms@^2.0.0:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==

nan@^2.15.0:
version "2.17.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb"
integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==

negotiator@^0.6.2:
version "0.6.3"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
Expand Down Expand Up @@ -597,9 +602,9 @@ semver@^6.0.0:
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.3.5:
version "7.3.7"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
dependencies:
lru-cache "^6.0.0"

Expand Down Expand Up @@ -628,17 +633,17 @@ socks-proxy-agent@^6.0.0:
socks "^2.6.2"

socks@^2.6.2:
version "2.7.0"
resolved "https://registry.yarnpkg.com/socks/-/socks-2.7.0.tgz#f9225acdb841e874dca25f870e9130990f3913d0"
integrity sha512-scnOe9y4VuiNUULJN72GrM26BNOjVsfPXI+j+98PkyEfsIXroa5ofyjT+FzGvn/xHs73U2JtoBYAVx9Hl4quSA==
version "2.7.1"
resolved "https://registry.yarnpkg.com/socks/-/socks-2.7.1.tgz#d8e651247178fde79c0663043e07240196857d55"
integrity sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==
dependencies:
ip "^2.0.0"
smart-buffer "^4.2.0"

sqlite3@^5.0.10:
version "5.0.10"
resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-5.0.10.tgz#64e1efb1b5a1ae343d2cc64ce9e582e5f5db24ba"
integrity sha512-xG4XPp7+b/lIlb/acs4XzBmmahI1Qq3Yhy+jZnZJivwB6DXpoOpGR6QinRbsQkHJIvMZyUsJDXouSva/JXcWFA==
version "5.1.2"
resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-5.1.2.tgz#f50d5b1482b6972fb650daf6f718e6507c6cfb0f"
integrity sha512-D0Reg6pRWAFXFUnZKsszCI67tthFD8fGPewRddDCX6w4cYwz3MbvuwRICbL+YQjBAh9zbw+lJ/V9oC8nG5j6eg==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.0"
node-addon-api "^4.2.0"
Expand Down Expand Up @@ -712,6 +717,13 @@ util-deprecate@^1.0.1:
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==

[email protected]:
version "1.6.0"
resolved "https://registry.yarnpkg.com/v8-profiler-next/-/v8-profiler-next-1.6.0.tgz#cea3e15a776d84ab0be94d2792823859ab3a4263"
integrity sha512-4+DMjIsOyD52cn90uohVMG4vgNwxYuB15O+6FfsH6QmCJI5QE7zIs91J1OVG6G6adsP5gV8cCfKB1bWFjrGsDQ==
dependencies:
nan "^2.15.0"

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
Expand Down
44 changes: 36 additions & 8 deletions app/src/main/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint global-require: off, no-console: off, promise/always-return: off */
/* eslint global-require: off, no-console: off, promise/always-return: off, import/first: off */

/**
* This module executes inside of electron's main process. You can start
Expand All @@ -8,7 +8,31 @@
* When running `npm run build` or `npm run build:main`, this file is compiled to
* `./src/main.js` using webpack. This gives us some performance wins.
*/
import { events, init, measure, profiler } from '@palette.dev/electron/main';
import {
events,
init,
measure,
network,
profiler,
} from '@palette.dev/electron/main';
import * as v8ProfilerNext from 'v8-profiler-next';

init({
key: 'cl8j2xvzc014708mq30m2vaqv',
// Collect click, performance events, and profiles
plugins: [
events(),
measure(),
profiler({ driver: v8ProfilerNext }),
network(),
],
});

// Sample the main process
profiler.start({
sampleInterval: 10,
});

import {
app,
BrowserWindow,
Expand All @@ -28,16 +52,20 @@ import { initMessageScheduler } from './messageScheduler';
import { NotificationsManager } from './notifications';
import { resolveHtmlPath } from './util';

init({
key: 'cl8j2xvzc014708mq30m2vaqv',
// Collect click, performance events, and profiles
plugins: [events(), measure(), profiler()],
});

const ONE_DAY_IN_MS = 1000 * 60 * 60 * 24;

let mainWindow: BrowserWindow | null = null;

// Profile the main process for 10s after startup
app
.whenReady()
.then(() => {
setTimeout(() => {
profiler.stop();
}, 10_000);
})
.catch(console.error);

class AppUpdater {
constructor() {
log.transports.file.level = 'info';
Expand Down
Loading

0 comments on commit 72bd758

Please sign in to comment.