mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-30 23:45:33 +03: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.: ![image](https://github.com/microsoft/playwright/assets/9798949/539028d0-3ef8-46f7-be2b-752f24604d18)
This commit is contained in:
parent
aba6964bd1
commit
6c3142959d
@ -87,7 +87,7 @@ export type JsonTestResultStart = {
|
||||
retry: number;
|
||||
workerIndex: number;
|
||||
parallelIndex: number;
|
||||
startTime: string;
|
||||
startTime: number;
|
||||
};
|
||||
|
||||
export type JsonAttachment = Omit<TestResult['attachments'][0], 'body'> & { base64?: string };
|
||||
@ -105,7 +105,7 @@ export type JsonTestStepStart = {
|
||||
parentStepId?: string;
|
||||
title: string;
|
||||
category: string,
|
||||
startTime: string;
|
||||
startTime: number;
|
||||
location?: Location;
|
||||
};
|
||||
|
||||
@ -232,7 +232,7 @@ export class TeleReporterReceiver {
|
||||
testResult.retry = payload.retry;
|
||||
testResult.workerIndex = payload.workerIndex;
|
||||
testResult.parallelIndex = payload.parallelIndex;
|
||||
testResult.startTime = new Date(payload.startTime);
|
||||
testResult.setStartTimeNumber(payload.startTime);
|
||||
testResult.statusEx = 'running';
|
||||
this._reporter.onTestBegin?.(test, testResult);
|
||||
}
|
||||
@ -510,22 +510,31 @@ class TeleTestStep implements TestStep {
|
||||
category: string;
|
||||
location: Location | undefined;
|
||||
parent: TestStep | undefined;
|
||||
startTime: Date;
|
||||
duration: number = -1;
|
||||
steps: TestStep[] = [];
|
||||
|
||||
private _startTime: number = 0;
|
||||
|
||||
constructor(payload: JsonTestStepStart, parentStep: TestStep | undefined, location: Location | undefined) {
|
||||
this.title = payload.title;
|
||||
this.category = payload.category;
|
||||
this.location = location;
|
||||
this.parent = parentStep;
|
||||
this.startTime = new Date(payload.startTime);
|
||||
this._startTime = payload.startTime;
|
||||
}
|
||||
|
||||
titlePath() {
|
||||
const parentPath = this.parent?.titlePath() || [];
|
||||
return [...parentPath, this.title];
|
||||
}
|
||||
|
||||
get startTime(): Date {
|
||||
return new Date(this._startTime);
|
||||
}
|
||||
|
||||
set startTime(value: Date) {
|
||||
this._startTime = +value;
|
||||
}
|
||||
}
|
||||
|
||||
class TeleTestResult implements reporterTypes.TestResult {
|
||||
@ -533,7 +542,6 @@ class TeleTestResult implements reporterTypes.TestResult {
|
||||
parallelIndex: reporterTypes.TestResult['parallelIndex'] = -1;
|
||||
workerIndex: reporterTypes.TestResult['workerIndex'] = -1;
|
||||
duration: reporterTypes.TestResult['duration'] = -1;
|
||||
startTime: reporterTypes.TestResult['startTime'] = new Date();
|
||||
stdout: reporterTypes.TestResult['stdout'] = [];
|
||||
stderr: reporterTypes.TestResult['stderr'] = [];
|
||||
attachments: reporterTypes.TestResult['attachments'] = [];
|
||||
@ -545,9 +553,23 @@ class TeleTestResult implements reporterTypes.TestResult {
|
||||
stepMap: Map<string, reporterTypes.TestStep> = new Map();
|
||||
statusEx: reporterTypes.TestResult['status'] | 'scheduled' | 'running' = 'scheduled';
|
||||
|
||||
private _startTime: number = 0;
|
||||
|
||||
constructor(retry: number) {
|
||||
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 };
|
||||
|
@ -199,7 +199,7 @@ export class TeleReporterEmitter implements ReporterV2 {
|
||||
retry: result.retry,
|
||||
workerIndex: result.workerIndex,
|
||||
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],
|
||||
title: step.title,
|
||||
category: step.category,
|
||||
startTime: step.startTime.toISOString(),
|
||||
startTime: +step.startTime,
|
||||
location: this._relativeLocation(step.location),
|
||||
};
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ class Reporter {
|
||||
distillStep(step) {
|
||||
return {
|
||||
...step,
|
||||
_startTime: undefined,
|
||||
startTime: undefined,
|
||||
duration: undefined,
|
||||
parent: undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user