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-06-29 20:31:51
Build Type | Parameters | Standard Librarygo build |
TinyStringtinygo build |
Size Reduction | Performance |
---|---|---|---|---|---|
π₯οΈ Default Native | -ldflags="-s -w" |
1.3 MB | 1.1 MB | -164.0 KB | β 12.5% |
π Default WASM | (default -opt=z) |
580.8 KB | 252.4 KB | -328.4 KB | β 56.5% |
π Ultra WASM | -no-debug -panic=trap -scheduler=none -gc=leaking -target wasm |
141.3 KB | 34.3 KB | -107.0 KB | π 75.8% |
π Speed WASM | -opt=2 -target wasm |
827.0 KB | 362.5 KB | -464.5 KB | β 56.2% |
π Debug WASM | -opt=0 -target wasm |
1.8 MB | 800.8 KB | -1.0 MB | β 56.3% |
π― Performance Summary
- π Peak Reduction: 75.8% (Best optimization)
- β Average WebAssembly Reduction: 61.2%
- β Average Native Reduction: 12.5%
- π¦ 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-06-29 20:32:08
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 | 752 B / 530.773 OP |
32 |
2.1ΞΌs |
- | - | - |
π TinyString | 1.5 KB / 110.544 OP |
49 |
10.6ΞΌs |
β 100.0% more | β 53.1% more | β Poor | |
π’ Number Processing | π Standard | 912 B / 481.078 OP |
42 |
2.4ΞΌs |
- | - | - |
π TinyString | 320 B / 596.006 OP |
17 |
2.0ΞΌs |
π 64.9% less | π 59.5% less | π Excellent | |
π Mixed Operations | π Standard | 400 B / 758.782 OP |
22 |
1.5ΞΌs |
- | - | - |
π TinyString | 432 B / 341.202 OP |
20 |
3.4ΞΌs |
β οΈ 8.0% more | β 9.1% less | β Fair |
π― Performance Summary
- πΎ Memory Efficiency: β Fair (Acceptable overhead) (14.4% average change)
- π’ Allocation Efficiency: β Good (Allocation efficient) (-5.2% 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.