GitXplorerGitXplorer
s

hakuna

public
1 stars
1 forks
0 issues

Commits

List of commits on branch main.
Verified
886e5ced9d429200e83540ccb9e581268d9fa342

chore: multi-platform ci build

ssgammon committed 7 months ago
Verified
0f66426886749a1d3a3660940b43de909cd87b58

chore: obligatory ci badge in readme

ssgammon committed 7 months ago
Verified
002e233759efecb1bb3d32199ed368634055a9ae

chore: readme cleanups

ssgammon committed 7 months ago
Verified
93764a1f4af035a0776215baab62be41d90c1f7e

chore: initial readme

ssgammon committed 7 months ago
Verified
231660e3d0f5af9e54a1efc59be8570c66ebfdd5

chore: standalone bun executable

ssgammon committed 7 months ago
Verified
dd638cdcb42a9d63b9e6b0db3b7df87c5fffe571

fix: provenance hash output

ssgammon committed 7 months ago

README

The README file for this repository.

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
            }
          },
        ]
      }
    }
  ]
}