Skip to content

Commit b90f4d9

Browse files
rubennortefacebook-github-bot
authored andcommitted
Refactor IPerformanceLogger as an interface
Summary: This type makes more sense as an interface, given a class would be a common implementation (and object types aren't supported in that case). It also adds the names of the parameters so it's easier to understand for implementers. Changelog: [General][Changed] - Changed type definition of IPerformanceLogger from object to interface Reviewed By: lunaleaps Differential Revision: D23449816 fbshipit-source-id: be872748827b123587f3f397da20f5545b0aae07
1 parent f0e80ae commit b90f4d9

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

Libraries/Utilities/createPerformanceLogger.js

+26-18
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,32 @@ type Timespan = {
2424
...
2525
};
2626

27-
export type IPerformanceLogger = {
28-
addTimeAnnotation(string, number, string | void): void,
29-
addTimespan(string, number, number, string | void): void,
30-
startTimespan(string, string | void): void,
31-
stopTimespan(string, options?: {update?: boolean}): void,
32-
clear(): void,
33-
clearCompleted(): void,
34-
currentTimestamp(): number,
35-
getTimespans(): {[key: string]: Timespan, ...},
36-
hasTimespan(string): boolean,
37-
setExtra(string, mixed): void,
38-
getExtras(): {[key: string]: mixed, ...},
39-
removeExtra(string): ?mixed,
40-
markPoint(string, number | void): void,
41-
getPoints(): {[key: string]: number, ...},
42-
logEverything(): void,
43-
...
44-
};
27+
export interface IPerformanceLogger {
28+
addTimeAnnotation(
29+
key: string,
30+
durationInMs: number,
31+
description?: string,
32+
): void;
33+
addTimespan(
34+
key: string,
35+
startTime: number,
36+
endTime: number,
37+
description?: string,
38+
): void;
39+
startTimespan(key: string, description?: string): void;
40+
stopTimespan(key: string, options?: {update?: boolean}): void;
41+
clear(): void;
42+
clearCompleted(): void;
43+
currentTimestamp(): number;
44+
getTimespans(): {[key: string]: Timespan, ...};
45+
hasTimespan(key: string): boolean;
46+
setExtra(key: string, value: mixed): void;
47+
getExtras(): {[key: string]: mixed, ...};
48+
removeExtra(key: string): ?mixed;
49+
markPoint(key: string, timestamp?: number): void;
50+
getPoints(): {[key: string]: number, ...};
51+
logEverything(): void;
52+
}
4553

4654
const _cookies: {[key: string]: number, ...} = {};
4755

0 commit comments

Comments
 (0)