github.com/gogf/gf@v1.16.9/os/grpool/grpool_bench_2_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). 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/gogf/gf. 6 7 // go test *.go -bench=".*" -count=1 8 9 package grpool_test 10 11 import ( 12 "testing" 13 14 "github.com/gogf/gf/os/grpool" 15 ) 16 17 var n = 500000 18 19 func BenchmarkGrpool2(b *testing.B) { 20 b.N = n 21 for i := 0; i < b.N; i++ { 22 grpool.Add(increment) 23 } 24 } 25 26 func BenchmarkGoroutine2(b *testing.B) { 27 b.N = n 28 for i := 0; i < b.N; i++ { 29 go increment() 30 } 31 }