From 5d4db43538a08eda8436da88b7fe92d829ec124f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 28 Nov 2015 23:07:25 +0200 Subject: [PATCH] Added a benchmark for writeHexInt --- bytesconv_timing_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bytesconv_timing_test.go b/bytesconv_timing_test.go index 10299e4..b0098b1 100644 --- a/bytesconv_timing_test.go +++ b/bytesconv_timing_test.go @@ -1,9 +1,28 @@ package fasthttp import ( + "bufio" + "bytes" "testing" ) +func BenchmarkWriteHexInt(b *testing.B) { + b.RunParallel(func(pb *testing.PB) { + var w bytes.Buffer + bw := bufio.NewWriter(&w) + i := 0 + for pb.Next() { + writeHexInt(bw, i) + i++ + if i > 0x7fffffff { + i = 0 + } + w.Reset() + bw.Reset(&w) + } + }) +} + func BenchmarkAppendUint(b *testing.B) { b.RunParallel(func(pb *testing.PB) { var buf []byte