Comparing version 0.0.1 to 0.0.2
12
index.js
@@ -5,3 +5,3 @@ function roundTo(decimalPlaces, numberToRound) { | ||
function startTimer() { | ||
function startTimer () { | ||
const time = process.hrtime() | ||
@@ -11,3 +11,3 @@ return time | ||
function endTimer(time) { | ||
function endTimer (time) { | ||
const diff = process.hrtime(time) | ||
@@ -20,3 +20,3 @@ const NS_PER_SEC = 1e9 | ||
function timer(fn, args, executions=100000) { | ||
function timer (fn, args, e) { | ||
const start = startTimer() | ||
@@ -29,4 +29,3 @@ for (var i = 1; i < executions; i++) { | ||
function timeIt (fn, args, r=100, e=100000) { | ||
function measure (fn, args, e=100000, r=1) { | ||
let results = [] | ||
@@ -36,3 +35,2 @@ for (let i = 0; i < r; i++) { | ||
} | ||
const result = results.reduce((pv, cv) => pv + cv, 0) | ||
@@ -42,2 +40,2 @@ return result / results.length | ||
module.exports = timeIt | ||
module.exports = measure |
{ | ||
"name": "timeit-js", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Performance Measuring for Node JS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# timeit-js | ||
Node Performance Measuring | ||
Simple Node Performance Measuring | ||
## Installation | ||
```sh | ||
npm i timeit-js | ||
``` | ||
## Import | ||
```js | ||
const timeit = require('timeit-js') | ||
``` | ||
## API | ||
```js | ||
/** | ||
* Test your function's execution time. | ||
* @params {Function} fn | ||
* @params {*} args | ||
* @params {Number} e Exections | ||
* @params {Number} r Repetitions | ||
*/ | ||
timeit.measure(fn, args, e, r=1) | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2838
27