test: tolerant timing assertion in the execution-time measure test
setTimeout can fire a few ms early under load (timer coalescing) — a 10ms sleep measured 9ms and failed the >=10 assertion, tripping a release gate. Sleep 25ms, assert >=20: the test verifies time is MEASURED, not the OS timer's precision.
This commit is contained in:
parent
d1ecee10f0
commit
4dc0a928fe
1 changed files with 5 additions and 2 deletions
|
|
@ -105,14 +105,17 @@ describe('TransactionManager', () => {
|
|||
const result = await manager.executeTransactionWithResult(async (tx) => {
|
||||
tx.addOperation({
|
||||
execute: async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, 10))
|
||||
await new Promise(resolve => setTimeout(resolve, 25))
|
||||
return async () => {}
|
||||
}
|
||||
})
|
||||
return 'done'
|
||||
})
|
||||
|
||||
expect(result.executionTimeMs).toBeGreaterThanOrEqual(10)
|
||||
// Timer coalescing can fire a setTimeout up to a few ms EARLY under
|
||||
// load, so assert well below the sleep — this tests that time is
|
||||
// MEASURED, not the OS timer's precision.
|
||||
expect(result.executionTimeMs).toBeGreaterThanOrEqual(20)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue