Code Monkey home page Code Monkey logo

overtake's Introduction

Overtake

Performance benchmark for NodeJS

Build Status NPM version Downloads Coverage Status Maintainability Snyk

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

overtake's People

Contributors

3axap4ehko avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.