mirror of https://github.com/vuejs/core.git
workflow: fix inaccurate test timer in benchmark (#286)
This commit is contained in:
parent
2ed0be8020
commit
b5ed2ec9bb
|
@ -72,8 +72,8 @@ const swapRows = wrap('swap', () => {
|
||||||
async function bench() {
|
async function bench() {
|
||||||
for (let i = 0; i < 30; i++) {
|
for (let i = 0; i < 30; i++) {
|
||||||
rows.value = []
|
rows.value = []
|
||||||
await defer()
|
|
||||||
await runLots()
|
await runLots()
|
||||||
|
await defer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
/* eslint-disable no-restricted-syntax */
|
/* eslint-disable no-restricted-syntax */
|
||||||
/* eslint-disable no-restricted-globals */
|
/* eslint-disable no-restricted-globals */
|
||||||
|
|
||||||
|
import { nextTick } from '@vue/vapor'
|
||||||
|
|
||||||
declare namespace globalThis {
|
declare namespace globalThis {
|
||||||
let doProfile: boolean
|
let doProfile: boolean
|
||||||
let reactivity: boolean
|
let reactivity: boolean
|
||||||
|
@ -29,13 +31,13 @@ export function wrap(
|
||||||
document.body.classList.remove('done')
|
document.body.classList.remove('done')
|
||||||
|
|
||||||
const { doProfile } = globalThis
|
const { doProfile } = globalThis
|
||||||
await defer()
|
await nextTick()
|
||||||
|
|
||||||
doProfile && console.profile(id)
|
doProfile && console.profile(id)
|
||||||
const start = performance.now()
|
const start = performance.now()
|
||||||
fn(...args)
|
fn(...args)
|
||||||
|
|
||||||
await defer()
|
await nextTick()
|
||||||
let time: number
|
let time: number
|
||||||
if (globalThis.reactivity) {
|
if (globalThis.reactivity) {
|
||||||
time = performance.measure(
|
time = performance.measure(
|
||||||
|
|
Loading…
Reference in New Issue