tl;dr; adding --bytecode and --production to bun build --compile gives a marginal boost.

I have a CLI tool called gg2 which is written in TypeScript and using Bun compiled to a single executable binary that can be installed with Homebrew. It's fast. Only 17% slower than GitHub's Go-compile gh CLI. But can it get even faster?

I read about Bytecode Caching which is supposed to make the executable "dramatically improved". Hmm. Let's see. There's also the --production option, which according to Set NODE_ENV=production and enable minification. Not convinced it's doing much but let's try.

I compiled the binary 4 different ways:

  • bun build src/index.ts --target=bun --compile --outfile out/gg
  • bun build src/index.ts --target=bun --compile --outfile out/gg-bytecode --bytecode
  • bun build src/index.ts --target=bun --compile --outfile out/gg-production --production
  • bun build src/index.ts --target=bun --compile --outfile out/gg-bytecode-production --production --bytecode

Then I ran hyperfine like this:


hyperfine "./out/gg --version" "./out/gg-bytecode --version" "./out/gg-production --version" "./out/gg-bytecode-production --version" --warmup 6

The results are as follows:

BINARY TIME (ms, smaller is better) SIZE (MB)
gg 87 58
gg-bytecode 81 60
gg-production 82.4 55
gg-bytecode-production 79.6 60

(sorry for being terrible at using Excel to draw charts)

Conclusion

I'm skeptical. The hyperfine often complains about statistical outliers so you have to run it with warmup and re-run it till it doesn't complain.

One caveat with using --bytecode is that the compiled code is not re-usable across different versions of bun but I don't understand how that's applicable if it's a executable binary that is shipped outside of Bun.

I'm going to add --bytecode and --production to the next release of gg2.

Comments

Your email will never ever be published.

Previous:
gg2 has a web page now January 5, 2026 JavaScript, TypeScript
Related by category:
Bun vs. Go for a basic web server benchmark October 24, 2025 Bun
Benchmarking oxlint vs biome December 12, 2025 Bun, TypeScript
Hosting your static web site with Firebase Hosting November 3, 2025 Bun
Testing out vite 8 on SPA: Vite 8 is 5x faster December 6, 2025 Bun, TypeScript
Related by keyword:
gg commit with suggested --no-verify August 29, 2025 Bun
gg2 is now installable with Homebrew December 8, 2025 Bun, TypeScript
How I end-to-end test my Bun CLI app September 18, 2025 Bun
hylite as an executable October 15, 2025 Linux, Bun, TypeScript