Skip to content

benchmarkMode: "time" does not respect minSamples #130

@RafaelGSS

Description

@RafaelGSS

E.g:

const { Suite } = require('bench-node');
const { spawn, spawnSync } = require('node:child_process')

async function spawnProcess() {
  const proc = spawn(
    process.execPath,
    [
      '-e',
      '1 + 1'
    ]);

  return new Promise((resolve) => {
    proc.on('exit', (code) => {
      resolve();
    })
  })
}

function spawnProcessSync() {
  const proc = spawnSync(
    process.execPath,
    [
      '-e',
      '1 + 1'
    ]);
}

const suite = new Suite({ benchmarkMode: "time" });

suite.add('Async spawnProcess', { minSamples: 30 }, async () => {
  await spawnProcess();
});

suite.add('Sync spawnProcess', { minSamples: 30 }, () => {
  spawnProcessSync();
});

suite.run();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions