Skip to content

Commit

Permalink
Added a benchmark function
Browse files Browse the repository at this point in the history
  • Loading branch information
agnivade committed Aug 4, 2017
1 parent 273bd3f commit 72ce568
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions grpool_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package grpool

import (
"io/ioutil"
"log"
"runtime"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -84,3 +86,18 @@ func TestRelease(t *testing.T) {

pool.WaitAll()
}

func BenchmarkPool(b *testing.B) {
// Testing with just 1 goroutine
// to benchmark the non-parallel part of the code
pool := NewPool(1, 10)
defer pool.Release()

log.SetOutput(ioutil.Discard)

for n := 0; n < b.N; n++ {
pool.JobQueue <- func() {
log.Printf("I am worker! Number %d\n", n)
}
}
}

0 comments on commit 72ce568

Please sign in to comment.