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() {