startup time tracking
Summary: Adds tracking from opening the application to the interface being shown. Reviewed By: passy Differential Revision: D9239037 fbshipit-source-id: eba60a9e839f9cc2b7a3c8706c6b9d63acb854b4
This commit is contained in:
committed by
Facebook Github Bot
parent
2b98f05d03
commit
a9b8c3d2c9
23
src/App.js
23
src/App.js
@@ -16,6 +16,7 @@ import BugReporterDialog from './chrome/BugReporterDialog.js';
|
|||||||
import ErrorBar from './chrome/ErrorBar.js';
|
import ErrorBar from './chrome/ErrorBar.js';
|
||||||
import PluginContainer from './PluginContainer.js';
|
import PluginContainer from './PluginContainer.js';
|
||||||
import PluginManager from './chrome/PluginManager.js';
|
import PluginManager from './chrome/PluginManager.js';
|
||||||
|
import {ipcRenderer} from 'electron';
|
||||||
|
|
||||||
import type Logger from './fb-stubs/Logger.js';
|
import type Logger from './fb-stubs/Logger.js';
|
||||||
import type BugReporter from './fb-stubs/BugReporter.js';
|
import type BugReporter from './fb-stubs/BugReporter.js';
|
||||||
@@ -33,13 +34,18 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class App extends React.Component<Props> {
|
export class App extends React.Component<Props> {
|
||||||
constructor(props: Props) {
|
|
||||||
performance.mark('init');
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.logger.trackTimeSince('init');
|
// track time since launch
|
||||||
|
const [s, ns] = process.hrtime();
|
||||||
|
const launchEndTime = s * 1e3 + ns / 1e6;
|
||||||
|
ipcRenderer.on('getLaunchTime', (event, launchStartTime) => {
|
||||||
|
this.props.logger.track(
|
||||||
|
'performance',
|
||||||
|
'launchTime',
|
||||||
|
launchEndTime - launchStartTime,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ipcRenderer.send('getLaunchTime');
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -65,7 +71,6 @@ export class App extends React.Component<Props> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
({
|
({
|
||||||
application: {pluginManagerVisible, bugDialogVisible, leftSidebarVisible},
|
application: {pluginManagerVisible, bugDialogVisible, leftSidebarVisible},
|
||||||
@@ -77,5 +82,7 @@ export default connect(
|
|||||||
selectedDevice,
|
selectedDevice,
|
||||||
error,
|
error,
|
||||||
}),
|
}),
|
||||||
{toggleBugDialogVisible},
|
{
|
||||||
|
toggleBugDialogVisible,
|
||||||
|
},
|
||||||
)(App);
|
)(App);
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
const {app, BrowserWindow} = require('electron');
|
|
||||||
|
const [s, ns] = process.hrtime();
|
||||||
|
let launchStartTime = s * 1e3 + ns / 1e6;
|
||||||
|
|
||||||
|
const {app, BrowserWindow, ipcMain} = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@@ -128,6 +132,16 @@ app.on('ready', function() {
|
|||||||
installExtension(REDUX_DEVTOOLS.id);
|
installExtension(REDUX_DEVTOOLS.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on('getLaunchTime', event => {
|
||||||
|
if (launchStartTime) {
|
||||||
|
event.sender.send('getLaunchTime', launchStartTime);
|
||||||
|
// set launchTime to null to only report it once, to prevents reporting wrong
|
||||||
|
// launch times for example after reloading the renderer process
|
||||||
|
launchStartTime = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function tryCreateWindow() {
|
function tryCreateWindow() {
|
||||||
if (appReady && pluginsCompiled) {
|
if (appReady && pluginsCompiled) {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
|
|||||||
Reference in New Issue
Block a user