Created
July 10, 2019 17:57
-
-
Save mzgoddard/82e2c5e53854a6a49fecdd17eb42a67c to your computer and use it in GitHub Desktop.
Time to open an electron window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()}`); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "electron-start", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"electron": "^5.0.6" | |
} | |
} |
Author
mzgoddard
commented
Jul 10, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment