From 08c338eebf67ef6c8c8fb7e3a91bbf89bbc2bb4c Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Mon, 9 Mar 2020 19:44:16 -0700 Subject: [PATCH] update JSTime to last call Summary: ChangeLog: [General] [Added] - support PerformanceLogger stopTimespan updates Reviewed By: alexeylang Differential Revision: D20095949 fbshipit-source-id: 3522a8d16ced44d6b699b294004371e223f9f619 --- Libraries/Utilities/createPerformanceLogger.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Libraries/Utilities/createPerformanceLogger.js b/Libraries/Utilities/createPerformanceLogger.js index fdd5ca9e3cf..2bfdb342581 100644 --- a/Libraries/Utilities/createPerformanceLogger.js +++ b/Libraries/Utilities/createPerformanceLogger.js @@ -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): 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() {