mirror of https://github.com/vuejs/core.git
workflow(benchmark): warmup run (#287)
This commit is contained in:
parent
b5ed2ec9bb
commit
2d30c71232
|
@ -10,7 +10,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="done">
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="./index.ts"></script>
|
<script type="module" src="./index.ts"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -9,6 +9,8 @@ import sirv from 'sirv'
|
||||||
import { launch } from 'puppeteer'
|
import { launch } from 'puppeteer'
|
||||||
import colors from 'picocolors'
|
import colors from 'picocolors'
|
||||||
import { exec, getSha } from '../scripts/utils.js'
|
import { exec, getSha } from '../scripts/utils.js'
|
||||||
|
import process from 'node:process'
|
||||||
|
import readline from 'node:readline'
|
||||||
|
|
||||||
// Thanks to https://github.com/krausest/js-framework-benchmark (Apache-2.0 license)
|
// Thanks to https://github.com/krausest/js-framework-benchmark (Apache-2.0 license)
|
||||||
const {
|
const {
|
||||||
|
@ -20,6 +22,7 @@ const {
|
||||||
noVapor,
|
noVapor,
|
||||||
port: portStr,
|
port: portStr,
|
||||||
count: countStr,
|
count: countStr,
|
||||||
|
warmupCount: warmupCountStr,
|
||||||
noHeadless,
|
noHeadless,
|
||||||
devBuild,
|
devBuild,
|
||||||
},
|
},
|
||||||
|
@ -56,6 +59,11 @@ const {
|
||||||
short: 'c',
|
short: 'c',
|
||||||
default: '30',
|
default: '30',
|
||||||
},
|
},
|
||||||
|
warmupCount: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'w',
|
||||||
|
default: '5',
|
||||||
|
},
|
||||||
noHeadless: {
|
noHeadless: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
@ -68,6 +76,7 @@ const {
|
||||||
|
|
||||||
const port = +(/** @type {string}*/ (portStr))
|
const port = +(/** @type {string}*/ (portStr))
|
||||||
const count = +(/** @type {string}*/ (countStr))
|
const count = +(/** @type {string}*/ (countStr))
|
||||||
|
const warmupCount = +(/** @type {string}*/ (warmupCountStr))
|
||||||
const sha = await getSha(true)
|
const sha = await getSha(true)
|
||||||
|
|
||||||
if (!skipLib) {
|
if (!skipLib) {
|
||||||
|
@ -226,22 +235,11 @@ async function doBench(browser, isVapor) {
|
||||||
await forceGC()
|
await forceGC()
|
||||||
const t = performance.now()
|
const t = performance.now()
|
||||||
|
|
||||||
for (let i = 0; i < count; i++) {
|
console.log('warmup run')
|
||||||
await clickButton('run') // test: create rows
|
await eachRun(() => withoutRecord(benchOnce), warmupCount)
|
||||||
await clickButton('update') // partial update
|
|
||||||
await clickButton('swaprows') // swap rows
|
|
||||||
await select() // test: select row, remove row
|
|
||||||
await clickButton('clear') // clear rows
|
|
||||||
|
|
||||||
await withoutRecord(() => clickButton('run'))
|
console.log('benchmark run')
|
||||||
await clickButton('add') // append rows to large table
|
await eachRun(benchOnce, count)
|
||||||
|
|
||||||
await withoutRecord(() => clickButton('clear'))
|
|
||||||
await clickButton('runLots') // create many rows
|
|
||||||
await withoutRecord(() => clickButton('clear'))
|
|
||||||
|
|
||||||
// TODO replace all rows
|
|
||||||
}
|
|
||||||
|
|
||||||
console.info(
|
console.info(
|
||||||
'Total time:',
|
'Total time:',
|
||||||
|
@ -261,6 +259,23 @@ async function doBench(browser, isVapor) {
|
||||||
await page.close()
|
await page.close()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
async function benchOnce() {
|
||||||
|
await clickButton('run') // test: create rows
|
||||||
|
await clickButton('update') // partial update
|
||||||
|
await clickButton('swaprows') // swap rows
|
||||||
|
await select() // test: select row, remove row
|
||||||
|
await clickButton('clear') // clear rows
|
||||||
|
|
||||||
|
await withoutRecord(() => clickButton('run'))
|
||||||
|
await clickButton('add') // append rows to large table
|
||||||
|
|
||||||
|
await withoutRecord(() => clickButton('clear'))
|
||||||
|
await clickButton('runLots') // create many rows
|
||||||
|
await withoutRecord(() => clickButton('clear'))
|
||||||
|
|
||||||
|
// TODO replace all rows
|
||||||
|
}
|
||||||
|
|
||||||
function getTimes() {
|
function getTimes() {
|
||||||
return page.evaluate(() => /** @type {any} */ (globalThis).times)
|
return page.evaluate(() => /** @type {any} */ (globalThis).times)
|
||||||
}
|
}
|
||||||
|
@ -273,9 +288,13 @@ async function doBench(browser, isVapor) {
|
||||||
|
|
||||||
/** @param {() => any} fn */
|
/** @param {() => any} fn */
|
||||||
async function withoutRecord(fn) {
|
async function withoutRecord(fn) {
|
||||||
|
const currentRecordTime = await page.evaluate(() => globalThis.recordTime)
|
||||||
await page.evaluate(() => (globalThis.recordTime = false))
|
await page.evaluate(() => (globalThis.recordTime = false))
|
||||||
await fn()
|
await fn()
|
||||||
await page.evaluate(() => (globalThis.recordTime = true))
|
await page.evaluate(
|
||||||
|
currentRecordTime => (globalThis.recordTime = currentRecordTime),
|
||||||
|
currentRecordTime,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {string} id */
|
/** @param {string} id */
|
||||||
|
@ -298,6 +317,23 @@ async function doBench(browser, isVapor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} bench
|
||||||
|
* @param {number} count
|
||||||
|
*/
|
||||||
|
async function eachRun(bench, count) {
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
readline.cursorTo(process.stdout, 0)
|
||||||
|
readline.clearLine(process.stdout, 0)
|
||||||
|
process.stdout.write(`${i + 1}/${count}`)
|
||||||
|
await bench()
|
||||||
|
}
|
||||||
|
if (count === 0) {
|
||||||
|
process.stdout.write('0/0 (skip)')
|
||||||
|
}
|
||||||
|
process.stdout.write('\n')
|
||||||
|
}
|
||||||
|
|
||||||
async function initBrowser() {
|
async function initBrowser() {
|
||||||
const disableFeatures = [
|
const disableFeatures = [
|
||||||
'Translate', // avoid translation popups
|
'Translate', // avoid translation popups
|
||||||
|
|
Loading…
Reference in New Issue