diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-29 13:38:35 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-29 13:38:35 +0200 |
commit | 741affeb8a4b001798f3dacc05f9b92de348f396 (patch) | |
tree | 7bef745ff25810da5d3b57ec8eb1341ab42b1f44 /bytesconv_timing_test.go | |
parent | Improved AppendUint tests (diff) | |
download | fasthttp-741affeb8a4b001798f3dacc05f9b92de348f396.tar.gz fasthttp-741affeb8a4b001798f3dacc05f9b92de348f396.tar.bz2 fasthttp-741affeb8a4b001798f3dacc05f9b92de348f396.zip |
added a benchmark for ParseUint
Diffstat (limited to 'bytesconv_timing_test.go')
-rw-r--r-- | bytesconv_timing_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bytesconv_timing_test.go b/bytesconv_timing_test.go index b0098b1..0d99f10 100644 --- a/bytesconv_timing_test.go +++ b/bytesconv_timing_test.go @@ -23,6 +23,21 @@ func BenchmarkWriteHexInt(b *testing.B) { }) } +func BenchmarkParseUint(b *testing.B) { + b.RunParallel(func(pb *testing.PB) { + buf := []byte("1234567") + for pb.Next() { + n, err := ParseUint(buf) + if err != nil { + b.Fatalf("unexpected error: %s", err) + } + if n != 1234567 { + b.Fatalf("unexpected result: %d. Expecting %s", n, buf) + } + } + }) +} + func BenchmarkAppendUint(b *testing.B) { b.RunParallel(func(pb *testing.PB) { var buf []byte |