groutine性能测试用例

This commit is contained in:
John
2018-01-16 15:01:36 +08:00
parent 0fec5128fb
commit df56025aab

View File

@ -13,21 +13,18 @@ import (
"gitee.com/johng/gf/g/os/groutine"
)
func test() {
num := 0
for i := 0; i < 1000000; i++ {
num += i
}
func increment() {
for i := 0; i < 1000000; i++ {}
}
func BenchmarkGroutine(b *testing.B) {
for i := 0; i < b.N; i++ {
groutine.Add(test)
groutine.Add(increment)
}
}
func BenchmarkGoRoutine(b *testing.B) {
for i := 0; i < b.N; i++ {
go test()
go increment()
}
}