Skip to content

Commit 08c338e

Browse files
sahrensfacebook-github-bot
authored andcommitted
update JSTime to last call
Summary: ChangeLog: [General] [Added] - support PerformanceLogger stopTimespan updates Reviewed By: alexeylang Differential Revision: D20095949 fbshipit-source-id: 3522a8d16ced44d6b699b294004371e223f9f619
1 parent c938c0a commit 08c338e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Libraries/Utilities/createPerformanceLogger.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Timespan = {
2929
export type IPerformanceLogger = {
3030
addTimespan(string, number, string | void): void,
3131
startTimespan(string, string | void): void,
32-
stopTimespan(string): void,
32+
stopTimespan(string, options?: {update?: boolean}): void,
3333
clear(): void,
3434
clearCompleted(): void,
3535
clearExceptTimespans(Array<string>): void,
@@ -107,7 +107,7 @@ function createPerformanceLogger(): IPerformanceLogger {
107107
}
108108
},
109109

110-
stopTimespan(key: string) {
110+
stopTimespan(key: string, options?: {update?: boolean}) {
111111
const timespan = this._timespans[key];
112112
if (!timespan || !timespan.startTime) {
113113
if (PRINT_TO_CONSOLE && __DEV__) {
@@ -118,7 +118,7 @@ function createPerformanceLogger(): IPerformanceLogger {
118118
}
119119
return;
120120
}
121-
if (timespan.endTime) {
121+
if (timespan.endTime && !options?.update) {
122122
if (PRINT_TO_CONSOLE && __DEV__) {
123123
infoLog(
124124
'PerformanceLogger: Attempting to end a timespan that has already ended ',
@@ -134,8 +134,10 @@ function createPerformanceLogger(): IPerformanceLogger {
134134
infoLog('PerformanceLogger.js', 'end: ' + key);
135135
}
136136

137-
Systrace.endAsyncEvent(key, _cookies[key]);
138-
delete _cookies[key];
137+
if (_cookies[key] != null) {
138+
Systrace.endAsyncEvent(key, _cookies[key]);
139+
delete _cookies[key];
140+
}
139141
},
140142

141143
clear() {

0 commit comments

Comments
 (0)