Socket
Socket
Sign inDemoInstall

@indutny/bencher

Package Overview
Dependencies
16
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

34

dist/bin/bencher.js

@@ -101,14 +101,22 @@ #!/usr/bin/env node

for (const m of modules) {
const paddedName = m.name + ' '.repeat(maxNameLength - m.name.length);
process.stdout.write(`${style(paddedName, BOLD)}: running...\n`);
const { ops, maxError, usedSamples } = run(m);
process.stdout.write(PREV_LINE);
process.stdout.write(`${style(paddedName, BOLD)}: ${ops.toFixed(1)} ops/s ` +
style(`(±${maxError.toFixed(1)}, p=${P_VALUE}, n=${usedSamples})`, ITALIC) +
'\n');
const paddedName = style(m.name, BOLD) + ':' + ' '.repeat(maxNameLength - m.name.length);
// Just to reserve the line
process.stdout.write('\n');
let ticks = 0;
const onTick = () => {
process.stdout.write(`${PREV_LINE}${paddedName} ${'.'.repeat(ticks)}\n`);
ticks = 1 + (ticks % 3);
};
onTick();
const { ops, maxError, usedSamples } = run(m, {
onTick,
});
const stats = style(`(±${nice(maxError)}, p=${P_VALUE}, n=${usedSamples})`, ITALIC);
process.stdout.write(`${PREV_LINE}${paddedName} ${nice(ops)} ops/sec ${stats}\n`);
}
}
function run(m) {
function run(m, { onTick }) {
const baseIterations = warmUp(m);
const samples = new Array();
const tickEvery = Math.round(m.options.samples / m.options.duration);
for (let i = 0; i < m.options.samples; i++) {

@@ -118,2 +126,5 @@ const iterations = baseIterations * (1 + (i % m.options.sweepWidth));

samples.push({ duration, iterations });
if (i % tickEvery === 0) {
onTick();
}
}

@@ -229,2 +240,9 @@ const { beta, confidence, outliers } = regress(m, samples);

}
function nice(n) {
let result = n.toFixed(1);
for (let i = result.length - 5; i > 0; i -= 3) {
result = result.slice(0, i) + "'" + result.slice(i);
}
return result;
}
main().catch((err) => {

@@ -231,0 +249,0 @@ console.error(err);

{
"name": "@indutny/bencher",
"version": "1.1.2",
"version": "1.1.3",
"description": "Simple benchmarking tool",

@@ -5,0 +5,0 @@ "bin": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc