Skip to content

kraiovsky/exacta

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Exacta πŸ†

Benchmarking library.

Features

  • Lightweight
  • Zero dependencies
  • Easy to use with your favourite test framework

Install

npm i exacta --save-dev
or
yarn add exacta --dev

Use

Among other use cases, you can run a benchmark as part of your test suite:

const Race = require('exacta')

const fn1 = require('./fn1')
const fn2 = require('./fn2')

const param1 = [1, 2, 3]
const param2 = 'your string'

test(`benchmark`, () => {
  new Race()
    .setRuns(100000) // optional, defaults to 1000
    .addFn(fn1) // add functions to run...
    .addFn(fn2) // ...as many as you have, one at a time
    .setParams(param1, param2) // add parameters that functions take
    .run() // and finally let them run
})

it will output something like this:

--= Race results =--

# of runs: 100000
Parameters: [[1,2,3],"your string"]

Function                Run time [↓]
====================================
πŸ† fn1()                10 ms
------------------------------------
   fn2()                20 ms
------------------------------------

Author

Roman Krayovskyy (rkrayovskyy@gmail.com)

The name

Exacta stands for a method of betting, as on a horserace, in which the bettor must correctly pick those finishing in the first and second places in precisely that sequence. (https://www.thefreedictionary.com/exacta)

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks