ops-per-sec
v3.0.0
Published
Quickly test ops per second of a function
Downloads
7
Maintainers
Readme
ops-per-sec

Quickly test ops per second of a function
Warning - eval like stuff going on in cli yo
When using the cli your string will be interpreted using Node's vm
in a
sandboxed context. I'm no expert on the dangers of that, but it's always better
to be safe than sorry. Don't be dumb with that.
"eval is evil" - some smart dude
Install
node
$ npm install --save ops-per-sec
cli
$ npm install -g ops-per-sec
Usage
const opsPerSec = require('ops-per-sec')
let ops = opsPerSec(() => ['some', 'text', 'in'].includes('text'), 3000, true)
console.log(`${ops} ops/sec`)
$ ops-per-sec "() => ['some', 'text', 'in'].includes('text')" 3000 true
API
opsPerSec(*func, *expect, *runForMs)
- func [function - required] function to test ops per second for
- runForMs [integer - optional - default: 5000] time in ms to let function run
- expect [optional] value you expect to be returned from function
License
MIT © Andrew Carpenter