Closed aybabtme closed 10 years ago
Besides the append()
calls it looks good to me. Sorry for the delay in reviewing it.
Before using append(dst, src...)
:
BenchmarkScanNumber 50000000 54.3 ns/op 55.25 MB/s
BenchmarkScanString 20000000 110 ns/op 90.27 MB/s
BenchmarkScanLongString 5000000 599 ns/op 95.15 MB/s
BenchmarkScanEscapedString 10000000 166 ns/op 108.13 MB/s
BenchmarkReadString 10000000 162 ns/op 61.69 MB/s
BenchmarkReadLongString 5000000 661 ns/op 86.11 MB/s
BenchmarkReadInt 20000000 76.9 ns/op 65.06 MB/s
BenchmarkReadFloat64 10000000 188 ns/op 84.80 MB/s
BenchmarkReadBool 50000000 63.6 ns/op 62.94 MB/s
After:
BenchmarkScanNumber 50000000 55.3 ns/op 54.27 MB/s
BenchmarkScanString 20000000 109 ns/op 91.71 MB/s
BenchmarkScanLongString 5000000 561 ns/op 101.57 MB/s
BenchmarkScanEscapedString 10000000 152 ns/op 118.31 MB/s
BenchmarkReadString 10000000 158 ns/op 62.99 MB/s
BenchmarkReadLongString 5000000 619 ns/op 92.07 MB/s
BenchmarkReadInt 50000000 65.2 ns/op 76.70 MB/s
BenchmarkReadFloat64 10000000 179 ns/op 89.03 MB/s
BenchmarkReadBool 50000000 60.5 ns/op 66.14 MB/s
:+1:
yay!
This is not perfect and I'm sure a better way could be found. It negatively affect performance on strings:
master:
This branch:
I think this is a hack and it's not very clean. I'd like to have input as to how this could be done better. Should there be another func that is delegated to once
n == len(s.scratch)
?I'll try that out next.