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
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