Comparing version 1.4.0 to 1.5.0
@@ -6,3 +6,2 @@ var Mocha = require('mocha'); | ||
var escapeRe = require('escape-string-regexp'); | ||
var microtime = require('microtime'); | ||
@@ -24,3 +23,16 @@ function filterOutliers(data) { | ||
function nanoSeconds(hrtime) { | ||
return hrtime[0] * 1e9 + hrtime[1]; | ||
} | ||
var iterationCount = 5000; | ||
function updateMetadata(test, iterations) { | ||
var averageOperationTimeNS = averageWithoutOutliers(iterations); | ||
test.metadata.iterations = iterationCount; | ||
test.metadata.duration = averageOperationTimeNS * iterationCount / 1000000; | ||
test.metadata.averageDurationInNanoSeconds = averageOperationTimeNS; | ||
test.metadata.operationsPrSecond = averageOperationTimeNS * 1e9; | ||
} | ||
module.exports = Mocha.interfaces['mocha-benchmark-ui'] = function(suite) { | ||
@@ -71,3 +83,2 @@ var suites = [suite]; | ||
var iterationCount = 5000; | ||
var isAsync = fn && fn.length > 0; | ||
@@ -84,3 +95,3 @@ | ||
indexes.forEach(function (i) { | ||
var start = microtime.now(); | ||
var start = process.hrtime(); | ||
if (isAsync) { | ||
@@ -103,3 +114,3 @@ promise = new Promise(function (resolve, reject) { | ||
result = result.then(function () { | ||
iterations[i] = microtime.now() - start; | ||
iterations[i] = nanoSeconds(process.hrtime(start)); | ||
return promise; | ||
@@ -109,7 +120,7 @@ }); | ||
result = promise.then(function () { | ||
iterations[i] = microtime.now() - start; | ||
iterations[i] = nanoSeconds(process.hrtime(start)); | ||
}); | ||
} | ||
} else { | ||
iterations[i] = microtime.now() - start; | ||
iterations[i] = nanoSeconds(process.hrtime(start)); | ||
} | ||
@@ -120,6 +131,6 @@ }); | ||
result.then(function () { | ||
test.metadata.duration = averageWithoutOutliers(iterations) * iterationCount / 1000; | ||
updateMetadata(test, iterations); | ||
}); | ||
} else { | ||
test.metadata.duration = averageWithoutOutliers(iterations) * iterationCount / 1000; | ||
updateMetadata(test, iterations); | ||
} | ||
@@ -129,5 +140,3 @@ | ||
}); | ||
test.metadata = { | ||
iterations: iterationCount | ||
}; | ||
test.metadata = {}; | ||
test.file = file; | ||
@@ -134,0 +143,0 @@ suite.addTest(test); |
{ | ||
"name": "chewbacca", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A benchmark tool for Mocha test that will run the body of each test many times.", | ||
@@ -16,3 +16,2 @@ "scripts": { | ||
"escape-string-regexp": "1.0.3", | ||
"microtime": "2.0.0", | ||
"minimist": "1.2.0", | ||
@@ -19,0 +18,0 @@ "passerror": "1.1.0", |
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
15711
6
327
- Removedmicrotime@2.0.0
- Removedbindings@1.2.1(transitive)
- Removedmicrotime@2.0.0(transitive)
- Removednan@2.0.9(transitive)