diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-28 23:07:25 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-28 23:07:25 +0200 |
commit | 5d4db43538a08eda8436da88b7fe92d829ec124f (patch) | |
tree | 40bfd2c3a529885928423468395c2cdfc7a939fc /bytesconv_timing_test.go | |
parent | Optimized AppendUint by using stack-based buffer instead of uintBufPool (diff) | |
download | fasthttp-5d4db43538a08eda8436da88b7fe92d829ec124f.tar.gz fasthttp-5d4db43538a08eda8436da88b7fe92d829ec124f.tar.bz2 fasthttp-5d4db43538a08eda8436da88b7fe92d829ec124f.zip |
Added a benchmark for writeHexInt
Diffstat (limited to 'bytesconv_timing_test.go')
-rw-r--r-- | bytesconv_timing_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
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 |