github.com/gogf/gf@v1.16.9/os/grpool/grpool_bench_1_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=".*" 8 9 package grpool_test 10 11 import ( 12 "testing" 13 14 "github.com/gogf/gf/os/grpool" 15 ) 16 17 func increment() { 18 for i := 0; i < 1000000; i++ { 19 } 20 } 21 22 func BenchmarkGrpool_1(b *testing.B) { 23 for i := 0; i < b.N; i++ { 24 grpool.Add(increment) 25 } 26 } 27 28 func BenchmarkGoroutine_1(b *testing.B) { 29 for i := 0; i < b.N; i++ { 30 go increment() 31 } 32 }