github.com/zhongdalu/gf@v1.0.0/g/os/grpool/grpool_bench_2_test.go (about)

     1  // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  // go test *.go -bench=".*" -count=1
     8  
     9  package grpool_test
    10  
    11  import (
    12  	"github.com/zhongdalu/gf/g/os/grpool"
    13  	"testing"
    14  )
    15  
    16  var n = 500000
    17  
    18  func BenchmarkGrpool2(b *testing.B) {
    19  	b.N = n
    20  	for i := 0; i < b.N; i++ {
    21  		grpool.Add(increment)
    22  	}
    23  }
    24  
    25  func BenchmarkGoroutine2(b *testing.B) {
    26  	b.N = n
    27  	for i := 0; i < b.N; i++ {
    28  		go increment()
    29  	}
    30  }