README
benny-vipu
run benny benchmarks in the browser headless using vipu
🔧 Install · 🧩 Example · 📜 API docs · 🔥 Releases · 💪🏼 Contribute · 🖐️ Help
Install
$ npm i benny-vipu -g
CLI
Usage: benny-vipu [options] <file>
<file> Benchmark filename to run
-c, --clear Clear screen between page reloads
-f, --force Force cache renewal
-d, --debug Print debug information
-p, --precision=n Results decimal precision digits (default: 2)
-s, --sort Sort results by winners (default: false)
-w, --width=n Ascii chart width (default: 30)
--min=n Minimum iteration samples (default: 3)
--max=n Maximum time in seconds (default: 1)
Example
import { suite, add, finish } from 'benny-vipu'
const container = document.body
const clear = () => (container.innerHTML = '')
const bench = async () => {
for (const count of [100, 1_000, 10_000]) {
await suite(
`insert ${count} elements`,
add('createElement/appendChild', () => {
clear()
for (let i = 0; i < count; i++) {
const div = document.createElement('div')
container.appendChild(div)
}
}),
add('html+=div + innerHTML', () => {
clear()
let html = ''
for (let i = 0; i < count; i++) {
html += '<div></div>'
}
container.innerHTML = html
}),
add('Array.fill.join() + innerHTML', () => {
clear()
container.innerHTML = Array(count).fill('<div></div>').join('')
}),
)
}
}
bench().then(finish)
API
Table of Contents
run
Runs a given benchmark file.
Parameters
filename
string The benchmark filenameoptions
Options (optional, defaultnew Options()
)options.clear
Clear screen between page reloadsoptions.force
Force cache renewaloptions.debug
Print debug informationoptions.precision
Results decimal precision digits (default: 2)options.sort
Sort results by winners (default: false)options.width
Ascii chart width (default: 30)options.minSamples
Minimum iteration samples (default: 3)options.maxTime
Maximum time in seconds (default: 1)
Contribute
All contributions are welcome!
License
MIT © 2021 stagas