Skip to content

Commit

Permalink
Refactor IPerformanceLogger as an interface
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rubennorte authored and facebook-github-bot committed Sep 3, 2020
1 parent f0e80ae commit b90f4d9
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions Libraries/Utilities/createPerformanceLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,32 @@ type Timespan = {
...
};

export type IPerformanceLogger = {
addTimeAnnotation(string, number, string | void): void,
addTimespan(string, number, number, string | void): void,
startTimespan(string, string | void): void,
stopTimespan(string, options?: {update?: boolean}): void,
clear(): void,
clearCompleted(): void,
currentTimestamp(): number,
getTimespans(): {[key: string]: Timespan, ...},
hasTimespan(string): boolean,
setExtra(string, mixed): void,
getExtras(): {[key: string]: mixed, ...},
removeExtra(string): ?mixed,
markPoint(string, number | void): void,
getPoints(): {[key: string]: number, ...},
logEverything(): void,
...
};
export interface IPerformanceLogger {
addTimeAnnotation(
key: string,
durationInMs: number,
description?: string,
): void;
addTimespan(
key: string,
startTime: number,
endTime: number,
description?: string,
): void;
startTimespan(key: string, description?: string): void;
stopTimespan(key: string, options?: {update?: boolean}): void;
clear(): void;
clearCompleted(): void;
currentTimestamp(): number;
getTimespans(): {[key: string]: Timespan, ...};
hasTimespan(key: string): boolean;
setExtra(key: string, value: mixed): void;
getExtras(): {[key: string]: mixed, ...};
removeExtra(key: string): ?mixed;
markPoint(key: string, timestamp?: number): void;
getPoints(): {[key: string]: number, ...};
logEverything(): void;
}

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

Expand Down

0 comments on commit b90f4d9

Please sign in to comment.