workflow: fix inaccurate test timer in benchmark (#286)

This commit is contained in:
Rizumu Ayaka 2024-11-11 17:01:44 +08:00 committed by GitHub
parent 2ed0be8020
commit b5ed2ec9bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -72,8 +72,8 @@ const swapRows = wrap('swap', () => {
async function bench() {
for (let i = 0; i < 30; i++) {
rows.value = []
await defer()
await runLots()
await defer()
}
}

View File

@ -2,6 +2,8 @@
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-restricted-globals */
import { nextTick } from '@vue/vapor'
declare namespace globalThis {
let doProfile: boolean
let reactivity: boolean
@ -29,13 +31,13 @@ export function wrap(
document.body.classList.remove('done')
const { doProfile } = globalThis
await defer()
await nextTick()
doProfile && console.profile(id)
const start = performance.now()
fn(...args)
await defer()
await nextTick()
let time: number
if (globalThis.reactivity) {
time = performance.measure(