add Systrace to all PerformanceLogger.js markers

Reviewed By: alexeylang

Differential Revision: D4567843

fbshipit-source-id: 00cac36d2b73f827723546a04edd6b89267c26bb
This commit is contained in:
Aaron Chiu 2017-02-17 11:50:44 -08:00 committed by Facebook Github Bot
parent 118e88393e
commit e81258a15b
1 changed files with 5 additions and 0 deletions

View File

@ -12,9 +12,11 @@
const BatchedBridge = require('BatchedBridge');
const performanceNow = global.nativePerformanceNow || require('fbjs/lib/performanceNow');
const Systrace = require('Systrace');
var timespans = {};
var extras = {};
var cookies = {};
/**
* This is meant to collect and log performance data in production, which means
@ -53,6 +55,7 @@ var PerformanceLogger = {
description: description,
startTime: performanceNow(),
};
cookies[key] = Systrace.beginAsyncEvent(key);
},
stopTimespan(key) {
@ -75,6 +78,8 @@ var PerformanceLogger = {
return;
}
Systrace.endAsyncEvent(key, cookies[key]);
delete cookies[key];
timespans[key].endTime = performanceNow();
timespans[key].totalTime =
timespans[key].endTime - timespans[key].startTime;