summaryrefslogtreecommitdiff
path: root/cli/js/web/performance.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/web/performance.ts')
-rw-r--r--cli/js/web/performance.ts50
1 files changed, 23 insertions, 27 deletions
diff --git a/cli/js/web/performance.ts b/cli/js/web/performance.ts
index eb0479b37..1acff9f75 100644
--- a/cli/js/web/performance.ts
+++ b/cli/js/web/performance.ts
@@ -8,7 +8,7 @@ let performanceEntries: PerformanceEntryList = [];
function findMostRecent(
name: string,
- type: "mark" | "measure"
+ type: "mark" | "measure",
): PerformanceEntry | undefined {
return performanceEntries
.slice()
@@ -32,12 +32,12 @@ function convertMarkToTimestamp(mark: string | number): number {
function filterByNameType(
name?: string,
- type?: "mark" | "measure"
+ type?: "mark" | "measure",
): PerformanceEntryList {
return performanceEntries.filter(
(entry) =>
(name ? entry.name === name : true) &&
- (type ? entry.entryType === type : true)
+ (type ? entry.entryType === type : true),
);
}
@@ -72,7 +72,7 @@ export class PerformanceEntryImpl implements PerformanceEntry {
name: string,
entryType: string,
startTime: number,
- duration: number
+ duration: number,
) {
this.#name = name;
this.#entryType = entryType;
@@ -111,7 +111,7 @@ export class PerformanceMarkImpl extends PerformanceEntryImpl
constructor(
name: string,
- { detail = null, startTime = now() }: PerformanceMarkOptions = {}
+ { detail = null, startTime = now() }: PerformanceMarkOptions = {},
) {
super(name, "mark", startTime, 0);
if (startTime < 0) {
@@ -133,11 +133,9 @@ export class PerformanceMarkImpl extends PerformanceEntryImpl
[customInspect](): string {
return this.detail
- ? `${this.constructor.name} {\n detail: ${inspect(this.detail, {
- depth: 3,
- })},\n name: "${this.name}",\n entryType: "${
- this.entryType
- }",\n startTime: ${this.startTime},\n duration: ${this.duration}\n}`
+ ? `${this.constructor.name} {\n detail: ${
+ inspect(this.detail, { depth: 3 })
+ },\n name: "${this.name}",\n entryType: "${this.entryType}",\n startTime: ${this.startTime},\n duration: ${this.duration}\n}`
: `${this.constructor.name} { detail: ${this.detail}, name: "${this.name}", entryType: "${this.entryType}", startTime: ${this.startTime}, duration: ${this.duration} }`;
}
}
@@ -161,7 +159,7 @@ export class PerformanceMeasureImpl extends PerformanceEntryImpl
startTime: number,
duration: number,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- detail: any = null
+ detail: any = null,
) {
super(name, "measure", startTime, duration);
this.#detail = cloneValue(detail);
@@ -180,11 +178,9 @@ export class PerformanceMeasureImpl extends PerformanceEntryImpl
[customInspect](): string {
return this.detail
- ? `${this.constructor.name} {\n detail: ${inspect(this.detail, {
- depth: 3,
- })},\n name: "${this.name}",\n entryType: "${
- this.entryType
- }",\n startTime: ${this.startTime},\n duration: ${this.duration}\n}`
+ ? `${this.constructor.name} {\n detail: ${
+ inspect(this.detail, { depth: 3 })
+ },\n name: "${this.name}",\n entryType: "${this.entryType}",\n startTime: ${this.startTime},\n duration: ${this.duration}\n}`
: `${this.constructor.name} { detail: ${this.detail}, name: "${this.name}", entryType: "${this.entryType}", startTime: ${this.startTime}, duration: ${this.duration} }`;
}
}
@@ -193,11 +189,11 @@ export class PerformanceImpl implements Performance {
clearMarks(markName?: string): void {
if (markName == null) {
performanceEntries = performanceEntries.filter(
- (entry) => entry.entryType !== "mark"
+ (entry) => entry.entryType !== "mark",
);
} else {
performanceEntries = performanceEntries.filter(
- (entry) => !(entry.name === markName && entry.entryType === "mark")
+ (entry) => !(entry.name === markName && entry.entryType === "mark"),
);
}
}
@@ -205,12 +201,12 @@ export class PerformanceImpl implements Performance {
clearMeasures(measureName?: string): void {
if (measureName == null) {
performanceEntries = performanceEntries.filter(
- (entry) => entry.entryType !== "measure"
+ (entry) => entry.entryType !== "measure",
);
} else {
performanceEntries = performanceEntries.filter(
(entry) =>
- !(entry.name === measureName && entry.entryType === "measure")
+ !(entry.name === measureName && entry.entryType === "measure"),
);
}
}
@@ -220,7 +216,7 @@ export class PerformanceImpl implements Performance {
}
getEntriesByName(
name: string,
- type?: "mark" | "measure"
+ type?: "mark" | "measure",
): PerformanceEntryList {
return filterByNameType(name, type);
}
@@ -230,7 +226,7 @@ export class PerformanceImpl implements Performance {
mark(
markName: string,
- options: PerformanceMarkOptions = {}
+ options: PerformanceMarkOptions = {},
): PerformanceMark {
// 3.1.1.1 If the global object is a Window object and markName uses the
// same name as a read only attribute in the PerformanceTiming interface,
@@ -243,17 +239,17 @@ export class PerformanceImpl implements Performance {
measure(
measureName: string,
- options?: PerformanceMeasureOptions
+ options?: PerformanceMeasureOptions,
): PerformanceMeasure;
measure(
measureName: string,
startMark?: string,
- endMark?: string
+ endMark?: string,
): PerformanceMeasure;
measure(
measureName: string,
startOrMeasureOptions: string | PerformanceMeasureOptions = {},
- endMark?: string
+ endMark?: string,
): PerformanceMeasure {
if (startOrMeasureOptions && typeof startOrMeasureOptions === "object") {
if (endMark) {
@@ -271,7 +267,7 @@ export class PerformanceImpl implements Performance {
"end" in startOrMeasureOptions
) {
throw new TypeError(
- "Cannot specify start, end, and duration together in options."
+ "Cannot specify start, end, and duration together in options.",
);
}
}
@@ -319,7 +315,7 @@ export class PerformanceImpl implements Performance {
endTime - startTime,
typeof startOrMeasureOptions === "object"
? startOrMeasureOptions.detail ?? null
- : null
+ : null,
);
performanceEntries.push(entry);
return entry;