# Bun benchmark

This benchmark mimics the sorts of things Jarred Sumner does for bun officially. These could get more `foxglove`-specifc if we wanted to.

Here's a sample run:

```shell
$ hyperfine "node index.js" "bun index.js" "deno --allow-net index.js" "python index.py" --warmup=100
Benchmark 1: node index.js
  Time (mean ± σ):      1.162 s ±  0.040 s    [User: 0.170 s, System: 0.015 s]
  Range (min … max):    1.119 s …  1.252 s    10 runs

Benchmark 2: bun index.js
  Time (mean ± σ):     685.1 ms ±  56.4 ms    [User: 33.4 ms, System: 25.0 ms]
  Range (min … max):   611.2 ms … 788.5 ms    10 runs

Benchmark 3: deno --allow-net index.js
  Time (mean ± σ):      1.060 s ±  0.033 s    [User: 0.039 s, System: 0.023 s]
  Range (min … max):    1.017 s …  1.120 s    10 runs

Benchmark 4: python index.py
  Time (mean ± σ):     740.0 ms ± 127.2 ms    [User: 53.2 ms, System: 36.4 ms]
  Range (min … max):   577.3 ms … 1025.5 ms    10 runs

Summary
  bun index.js ran
    1.08 ± 0.21 times faster than python index.py
    1.55 ± 0.14 times faster than deno --allow-net index.js
    1.70 ± 0.15 times faster than node index.js
```

## Getting Started

```shell
brew install hyperfine
./run.sh
```

## Disclaimer

This isn’t a scientific test for a variety of reasons (e.g., lumpy github.com latency, possible caching, etc.) but it has been run ~5 times with similar results. Take this with a grain of salt. Or rewrite it!
