@pjchender/function-benchmarker

1.0.5 • Public • Published

Function Benchmarker

Build status version Coverage Status

A simple benchmark for testing function performance. Through the package, you can compare the cost time of different functions.

Guide

Import '@pjchender/function-benchmarker` and make the function you want to test as a parameter. Function-benchmarker will return the cost time executing the function in milliseconds.

const benchmarker = require('@pjchender/function-benchmarker');

function jsonStringify() {
  JSON.stringify({
    foo: 'bar',
  });
}

const costTime = benchmarker(jsonStringify);
console.log('costTime', costTime);

API

By default, function-benchmarker will run the function to test for 1,000,000 times and calculate the cost time (ms). You can pass the times for executing the function as the second parameter.

const costTime = benchmarker(functionToTest, [times]);

Test

$ npm test

LICENSE

MIT

Package Sidebar

Install

npm i @pjchender/function-benchmarker

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

5.79 kB

Total Files

6

Last publish

Collaborators

  • pjchender