README
ΒΆ
TinyString Benchmark Suite
Automated benchmark tools to measure and compare performance between standard Go libraries and TinyString implementations.
Binary Size Comparison
Standard Library Example | TinyString Example
Last updated: 2025-08-04 01:21:40
| Build Type | Parameters | Standard Librarygo build |
TinyStringtinygo build |
Size Reduction | Performance |
|---|---|---|---|---|---|
| π₯οΈ Default Native | -ldflags="-s -w" |
1.4 MB | 1.2 MB | -152.0 KB | β 10.6% |
| π Default WASM | (default -opt=z) |
590.2 KB | 252.7 KB | -337.5 KB | β 57.2% |
| π Ultra WASM | -no-debug -panic=trap -scheduler=none -gc=leaking -target wasm |
141.2 KB | 27.5 KB | -113.6 KB | π 80.5% |
| π Speed WASM | -opt=2 -target wasm |
837.2 KB | 370.1 KB | -467.1 KB | β 55.8% |
| π Debug WASM | -opt=0 -target wasm |
1.8 MB | 819.8 KB | -1000.0 KB | β 55.0% |
π― Performance Summary
- π Peak Reduction: 80.5% (Best optimization)
- β Average WebAssembly Reduction: 62.1%
- β Average Native Reduction: 10.6%
- π¦ Total Size Savings: 2.0 MB across all builds
Performance Legend
- β Poor (<5% reduction)
- β Fair (5-15% reduction)
- β Good (15-70% reduction)
- π Outstanding (>70% reduction)
Memory Usage Comparison
Standard Library Example | TinyString Example
Last updated: 2025-08-04 01:21:57
Performance benchmarks comparing memory allocation patterns between standard Go library and TinyString:
| π§ͺ Benchmark Category | π Library | πΎ Memory/Op | π’ Allocs/Op | β±οΈ Time/Op | π Memory Trend | π― Alloc Trend | π Performance |
|---|---|---|---|---|---|---|---|
| π String Processing | π Standard | 808 B / 594.879 OP |
32 |
2.2ΞΌs |
- | - | - |
| π TinyString | 464 B / 208.210 OP |
17 |
5.7ΞΌs |
π 42.6% less | π 46.9% less | π Excellent | |
| π’ Number Processing | π Standard | 912 B / 494.260 OP |
42 |
2.5ΞΌs |
- | - | - |
| π TinyString | 320 B / 595.345 OP |
17 |
2.0ΞΌs |
π 64.9% less | π 59.5% less | π Excellent | |
| π Mixed Operations | π Standard | 416 B / 829.800 OP |
22 |
1.4ΞΌs |
- | - | - |
| π TinyString | 192 B / 429.885 OP |
12 |
2.7ΞΌs |
π 53.8% less | π 45.5% less | π Excellent |
π― Performance Summary
- πΎ Memory Efficiency: π Excellent (Lower memory usage) (-53.8% average change)
- π’ Allocation Efficiency: π Excellent (Fewer allocations) (-50.6% average change)
- π Benchmarks Analyzed: 3 categories
- π― Optimization Focus: Binary size reduction vs runtime efficiency
βοΈ Trade-offs Analysis
The benchmarks reveal important trade-offs between binary size and runtime performance:
π¦ Binary Size Benefits β
- π 16-84% smaller compiled binaries
- π Superior WebAssembly compression ratios
- π Faster deployment and distribution
- πΎ Lower storage requirements
π§ Runtime Memory Considerations β οΈ
- π Higher allocation overhead during execution
- ποΈ Increased GC pressure due to allocation patterns
- β‘ Trade-off optimizes for distribution size over runtime efficiency
- π Different optimization strategy than standard library
π― Optimization Recommendations
| π― Use Case | π‘ Recommendation | π§ Best For |
|---|---|---|
| π WebAssembly Apps | β TinyString | Size-critical web deployment |
| π± Embedded Systems | β TinyString | Resource-constrained devices |
| βοΈ Edge Computing | β TinyString | Fast startup and deployment |
| π’ Memory-Intensive Server | β οΈ Standard Library | High-throughput applications |
| π High-Frequency Processing | β οΈ Standard Library | Performance-critical workloads |
π Performance Legend
- π Excellent (Better performance)
- β Good (Acceptable trade-off)
- β οΈ Caution (Higher resource usage)
- β Poor (Significant overhead)
Quick Usage π
# Run complete benchmark (recommended)
./build-and-measure.sh
# Clean generated files
./clean-all.sh
# Update README with existing data only (does not re-run benchmarks)
./update-readme.sh
# Run all memory and binary size benchmarks (without updating README)
./run-all-benchmarks.sh
# Run only memory benchmarks
./memory-benchmark.sh
What Gets Measured π
- Binary Size Comparison: Native + WebAssembly builds with multiple optimization levels. This compares the compiled output size of projects using the standard Go library versus TinyString.
- Memory Allocation: Measures Bytes/op, Allocations/op, and execution time (ns/op) for benchmark categories. This helps in understanding the memory efficiency of TinyString compared to standard library operations.
- String Processing: Benchmarks operations like case conversion, text manipulation, etc.
- Number Processing: Benchmarks numeric formatting, conversion operations, etc.
- Mixed Operations: Benchmarks scenarios involving a combination of string and 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).
π Memory Optimization Guide: See MEMORY_REDUCTION.md for comprehensive techniques and best practices to replace Go standard libraries with TinyString's optimized implementations. Essential reading for efficient string and numeric processing in TinyGo WebAssembly applications.
Requirements
- Go 1.21+
- TinyGo (optional, but recommended for full WebAssembly testing and to achieve smallest binary sizes).
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): If you encounter permission errors when trying to run the shell scripts, make them executable:
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.