overtake
v0.1.1
Published
NodeJS performance benchmark
Downloads
41
Maintainers
Readme
Overtake
Performance benchmark for NodeJS
Table of Contents
Features
- CLI
- TypeScript support
- Running in thread worker
Installing
Using yarn:
$ yarn add -D overtake
Using npm:
$ npm install -D overtake
Examples
Public interface
Create a benchmark in __benchmarks__
folder
benchmark('mongodb vs postgres', () => {
// initialize a context for benchmark
setup(async () => {
const { Client } = await import('pg');
const postgres = new Client();
await postgres.connect();
const { MongoClient } = await import('mongob');
const mongo = new MongoClient(uri);
await mongo.connect();
return { postgres, mongo };
});
measure('mongodb inserts', ({ mongo } /* context */, next) => {
// prepare a collection
const database = mongo.db('overtake');
const test = database.collection('test');
return (data) => test.insertOne(data).then(next);
});
measure('postgres inserts', ({ postgres } /* context */, next) => {
// prepare a query
const query = 'INSERT INTO overtake(value) VALUES($1) RETURNING *';
return (data) => postgres.query(query, [data.value]).then(next);
});
teardown(async ({ mongo, postgres }) => {
await postgres.end();
await mongo.end();
});
perform('simple test', 100000, [[{ value: 'test' }]]);
});
Make sure you have installed used modules and run
yarn overtake
or
npx overtake
Inline support
npx overtake -i "class A{}" -i "function A() {}" -i "A = () => {};" -c 20000
⭐ Script
⇶ Suite
➤ Perform
✓ Measure class A{}
┌─────────┬──────────┬──────────┬──────────┬───────────┬───────┐
│ (index) │ med │ p95 │ p99 │ total │ count │
├─────────┼──────────┼──────────┼──────────┼───────────┼───────┤
│ 0.0005 │ 0.000551 │ 0.001493 │ 0.002344 │ 16.506385 │ 20000 │
└─────────┴──────────┴──────────┴──────────┴───────────┴───────┘
✓ Measure function A() {}
┌─────────┬─────────┬────────┬──────────┬──────────┬───────┐
│ (index) │ med │ p95 │ p99 │ total │ count │
├─────────┼─────────┼────────┼──────────┼──────────┼───────┤
│ 0.00008 │ 0.00009 │ 0.0003 │ 0.000441 │ 2.875578 │ 20000 │
└─────────┴─────────┴────────┴──────────┴──────────┴───────┘
✓ Measure A = () => {};
┌─────────┬─────────┬──────────┬──────────┬─────────┬───────┐
│ (index) │ med │ p95 │ p99 │ total │ count │
├─────────┼─────────┼──────────┼──────────┼─────────┼───────┤
│ 0.00008 │ 0.00012 │ 0.000331 │ 0.000601 │ 3.42556 │ 20000 │
└─────────┴─────────┴──────────┴──────────┴─────────┴───────┘
Please take a look at benchmarks to see more examples
Showcase
Already measured performance
License
License Apache-2.0 Copyright (c) 2021-present Ivan Zakharchanka