print out Performance markers to console

Differential Revision: D4585709

fbshipit-source-id: fe1f1f6b146854aa426e6186baf73ac2cf1784c8
This commit is contained in:
Aaron Chiu 2017-02-21 22:12:35 -08:00 committed by Facebook Github Bot
parent a0da13322b
commit 02daffbe9d
1 changed files with 8 additions and 0 deletions

View File

@ -18,6 +18,8 @@ var timespans = {};
var extras = {};
var cookies = {};
const PRINT_TO_CONSOLE = false;
/**
* This is meant to collect and log performance data in production, which means
* it needs to have minimal overhead.
@ -56,6 +58,9 @@ var PerformanceLogger = {
startTime: performanceNow(),
};
cookies[key] = Systrace.beginAsyncEvent(key);
if (__DEV__ && PRINT_TO_CONSOLE) {
console.log('PerformanceLogger.js', 'start: ' + key);
}
},
stopTimespan(key) {
@ -78,6 +83,9 @@ var PerformanceLogger = {
return;
}
if (__DEV__ && PRINT_TO_CONSOLE) {
console.log('PerformanceLogger.js', 'end: ' + key);
}
Systrace.endAsyncEvent(key, cookies[key]);
delete cookies[key];
timespans[key].endTime = performanceNow();