Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doesdev/ops-per-sec
Quickly test ops per second of a function
https://github.com/doesdev/ops-per-sec
Last synced: about 20 hours ago
JSON representation
Quickly test ops per second of a function
- Host: GitHub
- URL: https://github.com/doesdev/ops-per-sec
- Owner: doesdev
- Created: 2017-08-16T05:19:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T03:31:40.000Z (almost 5 years ago)
- Last Synced: 2024-10-10T12:48:49.194Z (about 1 month ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ops-per-sec [![NPM version](https://badge.fury.io/js/ops-per-sec.svg)](https://npmjs.org/package/ops-per-sec) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
> 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
```sh
$ npm install --save ops-per-sec
```cli
```sh
$ npm install -g ops-per-sec
```## Usage
```js
const opsPerSec = require('ops-per-sec')
let ops = opsPerSec(() => ['some', 'text', 'in'].includes('text'), 3000, true)
console.log(`${ops} ops/sec`)
``````sh
$ 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](https://github.com/doesdev)