README
ΒΆ
TinyString Benchmark Suite
Automated benchmark tools to measure and compare performance between standard Go libraries and TinyString implementations.
Quick Usage π
# Run complete benchmark (recommended)
./build-and-measure.sh
# Clean generated files
./clean-all.sh
# Update README with existing data only
./update-readme.sh
What Gets Measured π
- Binary Size Comparison: Native + WebAssembly builds with multiple optimization levels
- Memory Allocation: Bytes/op, allocations/op, execution time for 3 benchmark categories:
- String Processing: Case conversion, text manipulation
- Number Processing: Numeric formatting, conversion operations
- Mixed Operations: Combined string + numeric operations
Current Performance Status
Target: Achieve memory usage close to standard library while maintaining binary size benefits
Latest Results (Run ./build-and-measure.sh to update):
- β Binary Size: TinyString is 20-50% smaller than stdlib for WebAssembly
- β οΈ Memory Usage: Number Processing uses 1000% more memory (needs optimization)
Requirements
- Go 1.21+
- TinyGo (optional, but recommended for full WebAssembly testing)
Directory Structure
benchmark/
βββ analyzer.go # Main analysis program
βββ common.go # Shared utilities
βββ reporter.go # README update logic
βββ build-and-measure.sh # Main benchmark script
βββ memory-benchmark.sh # Memory benchmarks
βββ clean-all.sh # Cleanup script
βββ update-readme.sh # README updater
βββ run-all-benchmarks.sh # Run all benchmarks
βββ bench-binary-size/ # Binary size test programs
β βββ standard-lib/ # Standard library example
β βββ tinystring-lib/ # TinyString example
βββ bench-memory-alloc/ # Memory allocation benchmarks
βββ standard/ # Standard library memory tests
βββ tinystring/ # TinyString memory tests
βββ pointer-comparison/ # Pointer optimization tests
What the Scripts Do
build-and-measure.sh
- Compiles examples with multiple TinyGo optimization levels (-ultra, -speed, -debug)
- Measures binary sizes for both native and WebAssembly targets
- Runs memory allocation benchmarks
- Updates the main project README.md with current results
memory-benchmark.sh
- Executes Go memory benchmarks for standard library vs TinyString
- Measures bytes/operation, allocations/operation, and execution time
- Generates memory comparison data for README
clean-all.sh
- Removes all generated binaries (.exe, .wasm files)
- Cleans up temporary analysis files
update-readme.sh
- Updates only the benchmark sections in the main README
- Uses existing binary files (doesn't rebuild)
Example Output
π Starting binary size benchmark...
β
TinyGo found: tinygo version 0.37.0
π§Ή Cleaning previous files...
π¦ Building standard library example with multiple optimizations...
π¦ Building TinyString example with multiple optimizations...
π Analyzing sizes and updating README...
π§ Running memory allocation benchmarks...
β
Binary size analysis completed and README updated
β
Memory benchmarks completed and README updated
π Benchmark completed successfully!
π Generated files:
standard: 1.3MiB
tinystring: 1.1MiB
standard.wasm: 581KiB
tinystring.wasm: 230KiB
standard-ultra.wasm: 142KiB
tinystring-ultra.wasm: 23KiB
Troubleshooting
TinyGo Not Found:
β TinyGo is not installed. Building only standard Go binaries.
Install TinyGo from: https://tinygo.org/getting-started/install/
Permission Issues (Linux/macOS/WSL):
chmod +x *.sh
Build Failures:
- Ensure you're in the
benchmark/directory - Verify TinyString library is available in the parent directory
Documentation
ΒΆ
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.