Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chewbacca

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chewbacca - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

31

mocha-benchmark-ui.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc