Add ui performance tracker
Reviewed By: lblasa Differential Revision: D50121106 fbshipit-source-id: 54650de65e11c80ea776eafd85cdd5b7749a4fd4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5a5a509d4d
commit
6f7027bccd
@@ -44,6 +44,7 @@ import {loadTheme} from './utils/loadTheme';
|
||||
import {connectFlipperServerToStore} from './dispatcher/flipperServer';
|
||||
import {enableConnectivityHook} from './chrome/ConnectivityLogs';
|
||||
import ReactDOM from 'react-dom';
|
||||
import {uiPerfTracker} from './utils/UIPerfTracker';
|
||||
|
||||
class AppFrame extends React.Component<
|
||||
{logger: Logger; persistor: Persistor},
|
||||
@@ -142,6 +143,7 @@ function init(flipperServer: FlipperServer) {
|
||||
initLogTailer();
|
||||
|
||||
const logger = initLogger(store);
|
||||
uiPerfTracker._init();
|
||||
|
||||
setLoggerInstance(logger);
|
||||
startGlobalErrorHandling();
|
||||
|
||||
29
desktop/flipper-ui-core/src/utils/UIPerfTracker.tsx
Normal file
29
desktop/flipper-ui-core/src/utils/UIPerfTracker.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {getLogger} from 'flipper-common';
|
||||
|
||||
type UIPerfEvents = 'ui-perf-everything-finally-loaded-jeeeez';
|
||||
|
||||
class UIPerfTracker {
|
||||
private t0!: number;
|
||||
|
||||
_init() {
|
||||
this.t0 = performance.now();
|
||||
}
|
||||
|
||||
track(event: UIPerfEvents) {
|
||||
const tx = performance.now();
|
||||
getLogger().track('performance', event, {
|
||||
time: tx - this.t0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const uiPerfTracker = new UIPerfTracker();
|
||||
Reference in New Issue
Block a user