mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Track load time when profiling startup
This commit is contained in:
@@ -33,20 +33,23 @@ window.onload = function() {
|
||||
var devMode = loadSettings.devMode || !loadSettings.resourcePath.startsWith(process.resourcesPath + path.sep);
|
||||
|
||||
if (loadSettings.profileStartup) {
|
||||
profileStartup(cacheDir, loadSettings);
|
||||
profileStartup(cacheDir, loadSettings, Date.now() - startTime);
|
||||
} else {
|
||||
setupWindow(cacheDir, loadSettings);
|
||||
}
|
||||
|
||||
if (global.atom) {
|
||||
global.atom.loadTime = Date.now() - startTime;
|
||||
console.log('Window load time: ' + global.atom.getWindowLoadTime() + 'ms');
|
||||
setLoadTime(Date.now() - startTime);
|
||||
}
|
||||
} catch (error) {
|
||||
handleSetupError(error);
|
||||
}
|
||||
}
|
||||
|
||||
var setLoadTime = function(loadTime) {
|
||||
if (global.atom) {
|
||||
global.atom.loadTime = loadTime;
|
||||
console.log('Window load time: ' + global.atom.getWindowLoadTime() + 'ms');
|
||||
}
|
||||
}
|
||||
|
||||
var handleSetupError = function(error) {
|
||||
var currentWindow = require('remote').getCurrentWindow();
|
||||
currentWindow.setSize(800, 600);
|
||||
@@ -134,15 +137,17 @@ var setupVmCompatibility = function() {
|
||||
vm.Script.createContext = vm.createContext;
|
||||
}
|
||||
|
||||
var profileStartup = function(cacheDir, loadSettings) {
|
||||
var profileStartup = function(cacheDir, loadSettings, initialTime) {
|
||||
var profile = function() {
|
||||
console.profile('startup');
|
||||
try {
|
||||
var startTime = Date.now()
|
||||
setupWindow(cacheDir, loadSettings);
|
||||
} catch (error) {
|
||||
handleSetupError(error);
|
||||
} finally {
|
||||
console.profileEnd('startup');
|
||||
setLoadTime(Date.now() - startTime + initialTime);
|
||||
console.log("Switch to the Profiles tab to view the created startup profile")
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user