Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace all string building operations in the lexer with strings.Builder. Doing so shows significant performance improvements. BurntSushi still has a slight edge in CPU performance, but there's still much work to do on memory performance. name old time/op new time/op delta ParseToml-2 311µs ± 0% 273µs ± 3% -12.29% (p=0.008 n=5+5) UnmarshalToml-2 386µs ± 4% 349µs ± 3% -9.63% (p=0.008 n=5+5) UnmarshalBurntSushiToml-2 368µs ± 8% 341µs ± 2% ~ (p=0.056 n=5+5) name old alloc/op new alloc/op delta ParseToml-2 132kB ± 0% 118kB ± 0% -11.07% (p=0.008 n=5+5) UnmarshalToml-2 147kB ± 0% 133kB ± 0% -9.92% (p=0.008 n=5+5) UnmarshalBurntSushiToml-2 82.6kB ± 0% 82.6kB ± 0% ~ (p=1.000 n=5+5) name old allocs/op new allocs/op delta ParseToml-2 3.19k ± 0% 1.91k ± 0% -40.19% (p=0.008 n=5+5) UnmarshalToml-2 4.03k ± 0% 2.75k ± 0% -31.83% (p=0.008 n=5+5) UnmarshalBurntSushiToml-2 1.73k ± 0% 1.73k ± 0% ~ (all equal) Out of curiosity, I benchmarked the results of updating each function along the way to see how each change effected the overall performance: name \ time/op master lexKey lexLitStringAsString lexStringAsString ParseToml-2 311µs ± 0% 299µs ± 1% 290µs ± 3% 273µs ± 3% UnmarshalToml-2 386µs ± 4% 381µs ± 2% 364µs ± 2% 349µs ± 3% UnmarshalBurntSushiToml-2 368µs ± 8% 341µs ± 2% 345µs ± 5% 341µs ± 2% name \ alloc/op master lexKey lexLitStringAsString lexStringAsString ParseToml-2 132kB ± 0% 132kB ± 0% 125kB ± 0% 118kB ± 0% UnmarshalToml-2 147kB ± 0% 146kB ± 0% 140kB ± 0% 133kB ± 0% UnmarshalBurntSushiToml-2 82.6kB ± 0% 82.6kB ± 0% 82.6kB ± 0% 82.6kB ± 0% name \ allocs/op master lexKey lexLitStringAsString lexStringAsString ParseToml-2 3.19k ± 0% 2.86k ± 0% 2.49k ± 0% 1.91k ± 0% UnmarshalToml-2 4.03k ± 0% 3.70k ± 0% 3.33k ± 0% 2.75k ± 0% UnmarshalBurntSushiToml-2 1.73k ± 0% 1.73k ± 0% 1.73k ± 0% 1.73k ± 0% Benchmarks were run from the benchmark/ directory using: go test -bench=.*Toml -benchmem -count=5 ./...
- Loading branch information