speedrunner

0.1.0 • Public • Published

speedrunner

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.

Installation

npm i speedrunner

Example

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))
})()
 

API

speedrunner(function, repeats)

Takes an async function to test and a number of how many times the test should run. Repeats a Result.

Result

{
    repeats: number,
    total: number,
    average: number,
    min: number,
    max: number,
    print: function,
    vs: function
}

result.print()

Prints a simple log of the result.

result.vs(other_result)

Compares the result with a different one and logs it.

Readme

Keywords

none

Package Sidebar

Install

npm i speedrunner

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • kodedninja