Add ui performance tracker

Reviewed By: lblasa

Differential Revision: D50121106

fbshipit-source-id: 54650de65e11c80ea776eafd85cdd5b7749a4fd4
This commit is contained in:
Andrey Goncharov
2023-10-10 06:51:13 -07:00
committed by Facebook GitHub Bot
parent 5a5a509d4d
commit 6f7027bccd
2 changed files with 31 additions and 0 deletions

View 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();