bytebuffer_timing_test.go 512 B

1234567891011121314151617181920212223242526272829303132
  1. package bytebufferpool
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. func BenchmarkByteBufferWrite(b *testing.B) {
  7. s := []byte("foobarbaz")
  8. b.RunParallel(func(pb *testing.PB) {
  9. var buf ByteBuffer
  10. for pb.Next() {
  11. for i := 0; i < 100; i++ {
  12. buf.Write(s)
  13. }
  14. buf.Reset()
  15. }
  16. })
  17. }
  18. func BenchmarkBytesBufferWrite(b *testing.B) {
  19. s := []byte("foobarbaz")
  20. b.RunParallel(func(pb *testing.PB) {
  21. var buf bytes.Buffer
  22. for pb.Next() {
  23. for i := 0; i < 100; i++ {
  24. buf.Write(s)
  25. }
  26. buf.Reset()
  27. }
  28. })
  29. }