File: bytebuffer_timing_test.go

package info (click to toggle)
golang-github-valyala-bytebufferpool 0.0~git20160817.0.e746df9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, experimental
  • size: 96 kB
  • sloc: makefile: 2
file content (32 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package bytebufferpool

import (
	"bytes"
	"testing"
)

func BenchmarkByteBufferWrite(b *testing.B) {
	s := []byte("foobarbaz")
	b.RunParallel(func(pb *testing.PB) {
		var buf ByteBuffer
		for pb.Next() {
			for i := 0; i < 100; i++ {
				buf.Write(s)
			}
			buf.Reset()
		}
	})
}

func BenchmarkBytesBufferWrite(b *testing.B) {
	s := []byte("foobarbaz")
	b.RunParallel(func(pb *testing.PB) {
		var buf bytes.Buffer
		for pb.Next() {
			for i := 0; i < 100; i++ {
				buf.Write(s)
			}
			buf.Reset()
		}
	})
}