Skip to content

Instantly share code, notes, and snippets.

@mzgoddard
Created July 10, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzgoddard/82e2c5e53854a6a49fecdd17eb42a67c to your computer and use it in GitHub Desktop.
Save mzgoddard/82e2c5e53854a6a49fecdd17eb42a67c to your computer and use it in GitHub Desktop.
Time to open an electron window.
<div class="times"></div>
<script>
const now = Date.now();
setTimeout(function () {
const div = document.querySelector('.times');
const search = location.search.substring(1).split('&').map(pair => pair.split('=')).reduce((carry, [key, value]) => {
carry[key] = Number(value);
return carry;
}, {});
const render = Date.now();
div.innerHTML = `Time to start main process JS: ${search.main}
<br/>Time to create window: ${search.window} (${search.window - search.main})
<br/>Time to execute first client script: ${now} (${now - search.window})
<br/>Time to first render: ${render} (${render - now})`;
});
</script>
const mainStart = Date.now();
const electron = require('electron');
electron.app.on('ready', function() {
const window = new electron.BrowserWindow({
width: 640,
height: 480
});
window.loadURL(`file://${__dirname}/index.html?main=${mainStart}&window=${Date.now()}`);
});
{
"name": "electron-start",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"electron": "^5.0.6"
}
}
@mzgoddard
Copy link
Author

Screen Shot 0031-07-10 at 1 56 56 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment