How to use autocannon - 10 common examples

To help you get started, we’ve selected a few autocannon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nearform / udaru / packages / udaru-hapi-server / bench / util / runner.js View on Github external
headers: params.headers,
  body: params.body
}

// Create the test and finish handler.
const instance = Autocannon(opts, (err, result) => {
  if (err) {
    console.error(err)
    process.exit(-1)
  }

  console.log('Detailed Result:', '\n\n', result)
})

// Starts the test and shows a pretty progress bar while it runs
Autocannon.track(instance)
github davidmarkclements / fast-date / bench / http.js View on Github external
function run (opts, cb) {
  console.log('\n===========Benching ' + opts.title + '=============')
  var instance = autocannon(opts, cb)
  autocannon.track(instance)
}
github mcollina / autocannon-ci / autocannon-ci.js View on Github external
runner.on('bench', function (data, cannon) {
    process.stdout.write('==> ')
    autocannon.track(cannon)
    cannon.on('done', function () {
      console.log()
    })
  })
github nearform / node-clinic-bubbleprof-examples / server-side-rendering / stories.js View on Github external
]

const instance = autocannon({
  title: 'ssr-example',
  url,
  connections: 10,
  pipelining: 1,
  duration: 10,
  requests,
}, console.log)

process.once('SIGINT', () => {
  instance.stop()
})

autocannon.track(instance)
github fastify / fastify-etag / benchmarks / run.js View on Github external
const shoot = (port) => new Promise((resolve) => {
  const opts = {
    url: `http://localhost:${port}/`,
    connections: 100,
    pipelining: 4,
    duration: 30,
    timeout: 30
  }

  currentBenchmark = autocannon(opts)
  currentBenchmark.once('done', resolve)
  autocannon.track(currentBenchmark, { renderResultsTable: false })
})
github restify / node-restify / benchmark / lib / autocannon.js View on Github external
var instance = autocannon(opts, function onResult(err, result) {
        if (err) {
            cb(err);
            return;
        }

        if (save) {
            writeResult(handler, version, result);
        }

        cb();
    });

    if (opts.track && save) {
        autocannon.track(instance);
    }
}
github adobe / athena / src / engines / autocannonEngine.js View on Github external
});

        stats.rpsMap.push({
          count: stats.rpsCount,
          date: now,
        });

        stats.rpsCount = 0;
      }, 1000);

      engine.on('done', function(results) {
        delete stats.rpsCount;
        clearInterval(interval);
      });

      autocannon.track(engine, {
        renderProgressBar: true,
      });
    };
github nearform / udaru / packages / udaru-hapi-server / bench / util / volumeRunner.js View on Github external
duration: DURATION,
    connections: CONNECTIONS,
    headers: {
      authorization: 'ROOTid',
      org: 'CONCH'
    },
    requests: [
      {
        method: 'GET',
        path: getPath()
      }
    ],
    setupClient: setupClient
  }, onComplete)

  autocannon.track(instance, {renderProgressBar: !DEBUG})

  instance.on('response', onResponse)
}
github dazejs / daze / tools / benchmarks / benchmarks.ts View on Github external
async function run(lib: string, url: string) {
  const _targetPath = path.join(basePath, lib)

  const child = childProcess.spawn('node', [_targetPath], {
    stdio: 'inherit',
  });
  await sleep(2000)

  benchmarksMDStream.write('\n')
  benchmarksMDStream.write(`### ${lib}\n`)
  benchmarksMDStream.write('\n')

  const { requests, throughput } = await autocannon({
    ...opt,
    url,
  })
  child.kill()

  benchmarksMDStream.write(table([
    ['Stat', 'Avg', 'Stdev', 'Min'],
    ['Req/Sec', requests.average, requests.stddev, requests.min],
    ['Bytes/Sec', size(throughput.average), size(requests.stddev), size(requests.min)]
  ]))
  benchmarksMDStream.write('\n')
  benchmarksMDStream.write('\n')
}
github strongloop / loopback-next / benchmark / src / autocannon.ts View on Github external
title: string,
    urlPath: string,
    options: Omit = {},
  ): Promise {
    const config = {
      url: this.buildUrl(urlPath),
      duration: this.duration,
      title,
      ...options,
      headers: {
        'content-type': 'application/json',
        ...options.headers,
      },
    };

    const data = await autocannon(config);
    assert.equal(
      data.non2xx,
      0,
      'No request should have failed with non-2xx status code.',
    );
    const stats: EndpointStats = {
      requestsPerSecond: data.requests.average,
      latency: data.latency.average,
    };
    return stats;
  }

autocannon

Fast HTTP benchmarking tool written in Node.js

MIT
Latest version published 25 days ago

Package Health Score

89 / 100
Full package analysis

Popular autocannon functions