mirror of
https://github.com/status-im/react-native.git
synced 2025-02-21 21:58:18 +00:00
Support logging points from JS
Summary: We want to be able to log individual points from JS. Reviewed By: ejanzer Differential Revision: D10050400 fbshipit-source-id: eadd81a8cf70082998950c19a98c3de979eb148a
This commit is contained in:
parent
0ee23d0beb
commit
77e6c5e7cf
@ -26,6 +26,7 @@ type Timespan = {
|
||||
|
||||
let timespans: {[key: string]: Timespan} = {};
|
||||
let extras: {[key: string]: any} = {};
|
||||
let points: {[key: string]: number} = {};
|
||||
const cookies: {[key: string]: number} = {};
|
||||
|
||||
const PRINT_TO_CONSOLE: false = false; // Type as false to prevent accidentally committing `true`;
|
||||
@ -107,6 +108,7 @@ const PerformanceLogger = {
|
||||
clear() {
|
||||
timespans = {};
|
||||
extras = {};
|
||||
points = {};
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'clear');
|
||||
}
|
||||
@ -119,6 +121,7 @@ const PerformanceLogger = {
|
||||
}
|
||||
}
|
||||
extras = {};
|
||||
points = {};
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'clearCompleted');
|
||||
}
|
||||
@ -132,6 +135,7 @@ const PerformanceLogger = {
|
||||
return previous;
|
||||
}, {});
|
||||
extras = {};
|
||||
points = {};
|
||||
if (PRINT_TO_CONSOLE) {
|
||||
infoLog('PerformanceLogger.js', 'clearExceptTimespans', keys);
|
||||
}
|
||||
@ -188,6 +192,29 @@ const PerformanceLogger = {
|
||||
logExtras() {
|
||||
infoLog(extras);
|
||||
},
|
||||
|
||||
markPoint(key: string) {
|
||||
if (points[key]) {
|
||||
if (__DEV__) {
|
||||
infoLog(
|
||||
'PerformanceLogger: Attempting to mark a point that has been already logged ',
|
||||
key,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
points[key] = performanceNow();
|
||||
},
|
||||
|
||||
getPoints() {
|
||||
return points;
|
||||
},
|
||||
|
||||
logPoints() {
|
||||
for (const key in points) {
|
||||
infoLog(key + ': ' + points[key] + 'ms');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = PerformanceLogger;
|
||||
|
Loading…
x
Reference in New Issue
Block a user