ops-per-sec

3.0.0 • Public • Published

ops-per-sec NPM version js-standard-style

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

Package Sidebar

Install

npm i ops-per-sec

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

3.79 kB

Total Files

4

Last publish

Collaborators

  • doesdev