Use more performance.mark for suites (#154)

- Use more performance.mark for whole suites.
- Pre-build the mark strings upfront
This commit is contained in:
Camillo Bruni 2023-05-15 23:42:27 +02:00 committed by GitHub
parent 373580bec9
commit ac59c3fb1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -190,11 +190,19 @@ export class BenchmarkRunner {
}
async _runSuite(suite) {
const suitePrepareLabel = `suite-${suite.name}-prepare`;
const suiteStartLabel = `suite-${suite.name}-start`;
const suiteEndLabel = `suite-${suite.name}-end`;
performance.mark(suitePrepareLabel);
await this._prepareSuite(suite);
performance.mark(`start-suite-${suite.name}`);
performance.mark(suiteStartLabel);
for (const test of suite.tests)
await this._runTestAndRecordResults(suite, test);
performance.mark(`end-suite-${suite.name}`);
performance.mark(suiteEndLabel);
performance.measure(`suite-${suite.name}`, suiteStartLabel, suiteEndLabel);
}
async _prepareSuite(suite) {

View file

@ -167,9 +167,10 @@ describe("BenchmarkRunner", () => {
it("should run and record results for every test in suite", async () => {
assert.calledThrice(_runTestAndRecordResultsStub);
assert.calledWith(peformanceMarkSpy, "start-suite-Suite 1");
assert.calledWith(peformanceMarkSpy, "end-suite-Suite 1");
expect(peformanceMarkSpy.callCount).to.equal(2);
assert.calledWith(peformanceMarkSpy, "suite-Suite 1-prepare");
assert.calledWith(peformanceMarkSpy, "suite-Suite 1-start");
assert.calledWith(peformanceMarkSpy, "suite-Suite 1-end");
expect(peformanceMarkSpy.callCount).to.equal(3);
});
});
});