GithubHelp home page GithubHelp logo

elide-dev / hakuna Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sgammon/hakuna

2.0 0.0 0.0 97 KB

Cross-runtime benchmarking and comparison using Mitata

JavaScript 5.84% TypeScript 94.16%

hakuna's Introduction

hakuna

CI

Warning

This library has not been published to NPM yet.

Small utility for running mitata across several runtimes and preparing reports from the results.

Hakuna ships as both a TypeScript library and a Bun standalone executable.

Usage

First, write a benchmark and config file:

vim ./bench-spec.json
{
  "runtimes": ["node", "deno", "bun", "elide"],
  "suites": [
    ["./example.mjs", {"runtimes": ["node", "bun"]}],
    ["./another-case.mjs"]
  ]
}

This is just an example; obviously, you should set your own test file path.

vim ./example.mjs
bench('noop', () => {});
bench('noop2', () => {});

group('group', () => {
  baseline('baseline', () => {});
  bench('Date.now()', () => Date.now());
  bench('performance.now()', () => performance.now());
});

group({ name: 'group2', summary: false }, () => {
  bench('new Array(0)', () => new Array(0));
  bench('new Array(1024)', () => new Array(1024));
});

The symbols from Mitata are automatically available for your script.

Then, run:

npx hakuna ./bench-spec.json
yarn exec hakuna ./bench-spec.json
pnpx hakuna ./bench-spec.json
bun x hakuna ./bench-spec.json

# Or:
npm i -g hakuna
yarn i -g hakuna
pnpm i -g hakuna
bun i -g hakuna

# And:
hakuna ./bench-spec.json

And you get:

cat ./bench-results.json | jq .
{
  "all": [
    {
      "runtime": {
        "name": "node",
        "bin": "node",
        "resolved": "/Users/sam/.nvm/versions/node/v18.16.0/bin/node"
      },
      "suite": {
        "name": "example.mjs",
        "entry": "./tests/smoke/example.mjs",
        "resolved": "/Volumes/VAULTROOM/hakuna/tests/smoke/example.mjs",
        "runtimes": [
          "node",
          "bun",
          "elide"
        ],
        "args": [],
        "env": {},
        "sysEnv": true
      },
      "bench": {
        "benchmarks": [
          {
            "name": "noop",
            "group": null,
            "time": 500,
            "warmup": true,
            "baseline": false,
            "async": false,
            "stats": {
              "min": 0,
              "max": 225.03662109375,
              "p50": 0.06103515625,
              "p75": 0.06103515625,
              "p99": 0.08154296875,
              "p999": 0.18310546875,
              "avg": 0.063877119053025
            }
          },
        ]
      }
    }
  ]
}

hakuna's People

Contributors

sgammon avatar

Stargazers

Dario Valdespino 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.