Speedtesting/benchmarking library for async functions. It's a simple wrapper around the perf_hooks
standard module (Node > 8.5.0). Benchmark the speed of single functions or compare them with other ones.
npm i speedrunner
const test = require('speedrunner')
// dumb example1
async function one() {
await JSON.parse("{}")
}
// dumb example2
async function two() {
await JSON.parse("{}")
await JSON.parse("{}")
}
// the test itself
// tests can only run in async functions, because you must await them
(async function () {
(await test(one, 1000)).vs(await test(two, 10000))
})()
Takes an async function
to test and a number
of how many times the test should run. Repeats a Result
.
{
repeats: number,
total: number,
average: number,
min: number,
max: number,
print: function,
vs: function
}
Prints a simple log of the result.
Compares the result with a different one and logs it.