mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 05:07:44 +08:00
40 lines
702 B
Go
40 lines
702 B
Go
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
|
//
|
|
// 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.
|
|
|
|
package gtimer
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
ctx = context.TODO()
|
|
timer = New()
|
|
)
|
|
|
|
func Benchmark_Add(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
timer.Add(ctx, time.Hour, func(ctx context.Context) {
|
|
|
|
})
|
|
}
|
|
}
|
|
|
|
func Benchmark_PriorityQueue_Pop(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
timer.queue.Pop()
|
|
}
|
|
}
|
|
|
|
func Benchmark_StartStop(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
timer.Start()
|
|
timer.Stop()
|
|
}
|
|
}
|