billion-challenge

πŸš€ 1 Billion Challenge

A high-performance Node.js benchmark suite that tests various approaches to process 1 billion numbers efficiently.

🎯 One-Command Installation

Linux/macOS:

curl -sSL https://benchmark.isaksweb.xyz/install.sh | bash

Windows (Git Bash/WSL):

curl -sSL https://benchmark.isaksweb.xyz/install.sh | bash

Alternative with wget:

wget -qO- https://benchmark.isaksweb.xyz/install.sh | bash

πŸƒ Quick Start

After installation:

cd billion-challenge
pnpm test          # Quick test (100M numbers, ~30s)
pnpm full          # Full challenge (1B numbers, ~5min)
pnpm benchmark     # Detailed profiling with memory tracking

πŸ† Expected Performance Ranking

  1. πŸ₯‡ Mathematical Formula: ~0.001ms (O(1) complexity)
  2. πŸ₯ˆ Assembly Style Loop: ~2-5 seconds
  3. πŸ₯‰ Parallel Workers: ~1-3 seconds (depends on CPU cores)
  4. πŸ“Š Other Optimizations: ~3-8 seconds

πŸ’‘ Optimization Techniques Tested

πŸ› οΈ Manual Installation

If you prefer to inspect before running:

# Download the installer
curl -O https://benchmark.isaksweb.xyz/install.sh
chmod +x install.sh

# Review the script
cat install.sh

# Run manually
./install.sh

πŸ“Š System Requirements

πŸ”§ Advanced Usage

Custom Installation Directory

curl -sSL https://benchmark.isaksweb.xyz/install.sh | bash -s -- --dir=my-benchmark

Development Mode

# After installation
cd billion-challenge
pnpm dev           # Run with TypeScript directly
pnpm build:dev     # Development build with sourcemaps

Profiling and Analysis

pnpm benchmark     # Full profiling with GC tracking
pnpm profile       # V8 profiling (creates .prof files)

# Analyze V8 profile
node --prof-process isolate-*.log > profile.txt

πŸ“ˆ Sample Output

πŸ† PERFORMANCE RANKING:
Rank | Method                | Time        | Ops/Second  | Memory   | Speedup
   1 β”‚ πŸ†Mathematical Formula  β”‚      0.01ms β”‚   1.00e+13  β”‚   0.0MB  β”‚   1.00x
   2 β”‚   Assembly Style Loop   β”‚   2,134.56ms β”‚   4.68e+08  β”‚  15.2MB  β”‚   0.47x
   3 β”‚   Parallel Workers      β”‚   1,847.32ms β”‚   5.41e+08  β”‚  45.3MB  β”‚   0.54x

🀝 Contributing

Found a faster algorithm? Submit a PR!

  1. Fork this repository
  2. Add your optimization to src/billion-challenge.ts
  3. Test with pnpm benchmark
  4. Submit a pull request with benchmark results

πŸ“ License

MIT License - Feel free to use in your projects!


Built with ❀️ using TypeScript + esbuild for maximum performance