mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(blob): store startTime as a number (#24620)
Turns out the Date objects have noticeable footprint on large suites and storing them as umber is much cheaper, e.g.: 
This commit is contained in:
parent
aba6964bd1
commit
6c3142959d
@ -87,7 +87,7 @@ export type JsonTestResultStart = {
|
|||||||
retry: number;
|
retry: number;
|
||||||
workerIndex: number;
|
workerIndex: number;
|
||||||
parallelIndex: number;
|
parallelIndex: number;
|
||||||
startTime: string;
|
startTime: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type JsonAttachment = Omit<TestResult['attachments'][0], 'body'> & { base64?: string };
|
export type JsonAttachment = Omit<TestResult['attachments'][0], 'body'> & { base64?: string };
|
||||||
@ -105,7 +105,7 @@ export type JsonTestStepStart = {
|
|||||||
parentStepId?: string;
|
parentStepId?: string;
|
||||||
title: string;
|
title: string;
|
||||||
category: string,
|
category: string,
|
||||||
startTime: string;
|
startTime: number;
|
||||||
location?: Location;
|
location?: Location;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ export class TeleReporterReceiver {
|
|||||||
testResult.retry = payload.retry;
|
testResult.retry = payload.retry;
|
||||||
testResult.workerIndex = payload.workerIndex;
|
testResult.workerIndex = payload.workerIndex;
|
||||||
testResult.parallelIndex = payload.parallelIndex;
|
testResult.parallelIndex = payload.parallelIndex;
|
||||||
testResult.startTime = new Date(payload.startTime);
|
testResult.setStartTimeNumber(payload.startTime);
|
||||||
testResult.statusEx = 'running';
|
testResult.statusEx = 'running';
|
||||||
this._reporter.onTestBegin?.(test, testResult);
|
this._reporter.onTestBegin?.(test, testResult);
|
||||||
}
|
}
|
||||||
@ -510,22 +510,31 @@ class TeleTestStep implements TestStep {
|
|||||||
category: string;
|
category: string;
|
||||||
location: Location | undefined;
|
location: Location | undefined;
|
||||||
parent: TestStep | undefined;
|
parent: TestStep | undefined;
|
||||||
startTime: Date;
|
|
||||||
duration: number = -1;
|
duration: number = -1;
|
||||||
steps: TestStep[] = [];
|
steps: TestStep[] = [];
|
||||||
|
|
||||||
|
private _startTime: number = 0;
|
||||||
|
|
||||||
constructor(payload: JsonTestStepStart, parentStep: TestStep | undefined, location: Location | undefined) {
|
constructor(payload: JsonTestStepStart, parentStep: TestStep | undefined, location: Location | undefined) {
|
||||||
this.title = payload.title;
|
this.title = payload.title;
|
||||||
this.category = payload.category;
|
this.category = payload.category;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.parent = parentStep;
|
this.parent = parentStep;
|
||||||
this.startTime = new Date(payload.startTime);
|
this._startTime = payload.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
titlePath() {
|
titlePath() {
|
||||||
const parentPath = this.parent?.titlePath() || [];
|
const parentPath = this.parent?.titlePath() || [];
|
||||||
return [...parentPath, this.title];
|
return [...parentPath, this.title];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get startTime(): Date {
|
||||||
|
return new Date(this._startTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
set startTime(value: Date) {
|
||||||
|
this._startTime = +value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TeleTestResult implements reporterTypes.TestResult {
|
class TeleTestResult implements reporterTypes.TestResult {
|
||||||
@ -533,7 +542,6 @@ class TeleTestResult implements reporterTypes.TestResult {
|
|||||||
parallelIndex: reporterTypes.TestResult['parallelIndex'] = -1;
|
parallelIndex: reporterTypes.TestResult['parallelIndex'] = -1;
|
||||||
workerIndex: reporterTypes.TestResult['workerIndex'] = -1;
|
workerIndex: reporterTypes.TestResult['workerIndex'] = -1;
|
||||||
duration: reporterTypes.TestResult['duration'] = -1;
|
duration: reporterTypes.TestResult['duration'] = -1;
|
||||||
startTime: reporterTypes.TestResult['startTime'] = new Date();
|
|
||||||
stdout: reporterTypes.TestResult['stdout'] = [];
|
stdout: reporterTypes.TestResult['stdout'] = [];
|
||||||
stderr: reporterTypes.TestResult['stderr'] = [];
|
stderr: reporterTypes.TestResult['stderr'] = [];
|
||||||
attachments: reporterTypes.TestResult['attachments'] = [];
|
attachments: reporterTypes.TestResult['attachments'] = [];
|
||||||
@ -545,9 +553,23 @@ class TeleTestResult implements reporterTypes.TestResult {
|
|||||||
stepMap: Map<string, reporterTypes.TestStep> = new Map();
|
stepMap: Map<string, reporterTypes.TestStep> = new Map();
|
||||||
statusEx: reporterTypes.TestResult['status'] | 'scheduled' | 'running' = 'scheduled';
|
statusEx: reporterTypes.TestResult['status'] | 'scheduled' | 'running' = 'scheduled';
|
||||||
|
|
||||||
|
private _startTime: number = 0;
|
||||||
|
|
||||||
constructor(retry: number) {
|
constructor(retry: number) {
|
||||||
this.retry = retry;
|
this.retry = retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setStartTimeNumber(startTime: number) {
|
||||||
|
this._startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
get startTime(): Date {
|
||||||
|
return new Date(this._startTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
set startTime(value: Date) {
|
||||||
|
this._startTime = +value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TeleFullProject = FullProject & { id: string };
|
export type TeleFullProject = FullProject & { id: string };
|
||||||
|
|||||||
@ -199,7 +199,7 @@ export class TeleReporterEmitter implements ReporterV2 {
|
|||||||
retry: result.retry,
|
retry: result.retry,
|
||||||
workerIndex: result.workerIndex,
|
workerIndex: result.workerIndex,
|
||||||
parallelIndex: result.parallelIndex,
|
parallelIndex: result.parallelIndex,
|
||||||
startTime: result.startTime.toISOString(),
|
startTime: +result.startTime,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ export class TeleReporterEmitter implements ReporterV2 {
|
|||||||
parentStepId: (step.parent as any)?.[idSymbol],
|
parentStepId: (step.parent as any)?.[idSymbol],
|
||||||
title: step.title,
|
title: step.title,
|
||||||
category: step.category,
|
category: step.category,
|
||||||
startTime: step.startTime.toISOString(),
|
startTime: +step.startTime,
|
||||||
location: this._relativeLocation(step.location),
|
location: this._relativeLocation(step.location),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ class Reporter {
|
|||||||
distillStep(step) {
|
distillStep(step) {
|
||||||
return {
|
return {
|
||||||
...step,
|
...step,
|
||||||
|
_startTime: undefined,
|
||||||
startTime: undefined,
|
startTime: undefined,
|
||||||
duration: undefined,
|
duration: undefined,
|
||||||
parent: undefined,
|
parent: undefined,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user