gf/g/os/grpool/grpool_bench_1_test.go

30 lines
647 B
Go
Raw Normal View History

// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
2018-01-17 10:28:42 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
2018-01-17 10:28:42 +08:00
// go test *.go -bench=".*"
package grpool_test
import (
"testing"
"github.com/gogf/gf/g/os/grpool"
2018-01-17 10:28:42 +08:00
)
2018-12-17 19:26:59 +08:00
func increment() {
2018-01-17 10:28:42 +08:00
for i := 0; i < 1000000; i++ {}
}
func BenchmarkGrpool_1(b *testing.B) {
for i := 0; i < b.N; i++ {
2018-12-17 19:26:59 +08:00
grpool.Add(increment)
2018-01-17 10:28:42 +08:00
}
}
func BenchmarkGoroutine_1(b *testing.B) {
for i := 0; i < b.N; i++ {
2018-12-17 19:26:59 +08:00
go increment()
}
}