update JSTime to last call

Summary: ChangeLog: [General] [Added] - support PerformanceLogger stopTimespan updates

Reviewed By: alexeylang

Differential Revision: D20095949

fbshipit-source-id: 3522a8d16ced44d6b699b294004371e223f9f619
This commit is contained in:
Spencer Ahrens
2020-03-09 19:44:16 -07:00
committed by Facebook Github Bot
parent c938c0afbf
commit 08c338eebf
@@ -29,7 +29,7 @@ type Timespan = {
export type IPerformanceLogger = {
addTimespan(string, number, string | void): void,
startTimespan(string, string | void): void,
stopTimespan(string): void,
stopTimespan(string, options?: {update?: boolean}): void,
clear(): void,
clearCompleted(): void,
clearExceptTimespans(Array<string>): void,
@@ -107,7 +107,7 @@ function createPerformanceLogger(): IPerformanceLogger {
}
},
stopTimespan(key: string) {
stopTimespan(key: string, options?: {update?: boolean}) {
const timespan = this._timespans[key];
if (!timespan || !timespan.startTime) {
if (PRINT_TO_CONSOLE && __DEV__) {
@@ -118,7 +118,7 @@ function createPerformanceLogger(): IPerformanceLogger {
}
return;
}
if (timespan.endTime) {
if (timespan.endTime && !options?.update) {
if (PRINT_TO_CONSOLE && __DEV__) {
infoLog(
'PerformanceLogger: Attempting to end a timespan that has already ended ',
@@ -134,8 +134,10 @@ function createPerformanceLogger(): IPerformanceLogger {
infoLog('PerformanceLogger.js', 'end: ' + key);
}
Systrace.endAsyncEvent(key, _cookies[key]);
delete _cookies[key];
if (_cookies[key] != null) {
Systrace.endAsyncEvent(key, _cookies[key]);
delete _cookies[key];
}
},
clear() {