From 741affeb8a4b001798f3dacc05f9b92de348f396 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 29 Nov 2015 13:38:35 +0200 Subject: [PATCH] added a benchmark for ParseUint --- bytesconv_timing_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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