Skip to content

Commit 97432f9

Browse files
committed
perf(runner): Use globalThis.performance.now instead of Date.now
1 parent 83638eb commit 97432f9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/runner/src/collect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getHooks, setHooks } from './map'
1717
import { collectorContext } from './context'
1818
import { runSetupFiles } from './setup'
1919

20-
const now = Date.now
20+
const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now
2121

2222
export async function collectTests(
2323
paths: string[],

packages/runner/src/run.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { hasFailed, hasTests } from './utils/tasks'
2727
import { PendingError } from './errors'
2828
import { callFixtureCleanup } from './fixture'
2929

30-
const now = Date.now
30+
const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now
3131

3232
function updateSuiteHookState(
3333
suite: Task,
@@ -181,7 +181,7 @@ export async function runTest(test: Test | Custom, runner: VitestRunner): Promis
181181

182182
test.result = {
183183
state: 'run',
184-
startTime: start,
184+
startTime: Date.now(),
185185
retryCount: 0,
186186
}
187187
updateTask(test, runner)
@@ -376,7 +376,7 @@ export async function runSuite(suite: Suite, runner: VitestRunner): Promise<void
376376

377377
suite.result = {
378378
state: 'run',
379-
startTime: start,
379+
startTime: Date.now(),
380380
}
381381

382382
updateTask(suite, runner)

0 commit comments

Comments
 (0)