Guest User

go sync.Pool bench

a guest
Feb 12th, 2016
341
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "testing"
  5. )
  6.  
  7. func Benchmark_withoutPool(b *testing.B) {
  8.     p := NoPool{}
  9.     b.N = b.N * 10
  10.     for i := 0; i < b.N; i++ {
  11.         p.Process()
  12.     }
  13.     b.ReportAllocs()
  14. }
  15.  
  16. func Benchmark_withPool(b *testing.B) {
  17.     p := WithPool{}
  18.     b.N = b.N * 10
  19.     for i := 0; i < b.N; i++ {
  20.         p.Process()
  21.     }
  22.     b.ReportAllocs()
  23. }
RAW Paste Data