Skip to content

Commit

Permalink
chore: readme cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jun 7, 2024
1 parent 93764a1 commit 002e233
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
Small utility for running [`mitata`](https://github.com/evanwashere/mitata) across several runtimes and preparing reports from the results.

## Usage
Hakuna ships as both a TypeScript library and a [Bun standalone executable](https://bun.sh/docs/bundler/executables).

**First, you:**
```
npm i --save-dev hakuna
yarn add --dev hakuna
pnpm i --save-dev hakuna
bun add --dev hakuna
```
## Usage

**Then, you make a benchmark spec file:**
**First, write a benchmark and config file:**

```
vim ./bench-spec.json
Expand All @@ -25,19 +19,51 @@ vim ./bench-spec.json
{
"runtimes": ["node", "deno", "bun", "elide"],
"suites": [
["./tests/smoke/example.mjs", {"runtimes": ["node", "bun"]}],
["./tests/smoke/json.mjs"],
["./tests/smoke/fs.mjs"]
["./example.mjs", {"runtimes": ["node", "bun"]}],
["./another-case.mjs"]
]
}
```

> This is just an example; obviously, you should set your own test file path.
**Finally, you:**
```
vim ./example.mjs
```
```javascript
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](https://github.com/evanwashere/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:**
Expand Down

0 comments on commit 002e233

Please sign in to comment.