github.com/gogf/gf/v2@v2.7.4/os/gtimer/gtimer_z_bench_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 package gtimer 8 9 import ( 10 "context" 11 "testing" 12 "time" 13 ) 14 15 var ( 16 ctx = context.TODO() 17 timer = New() 18 ) 19 20 func Benchmark_Add(b *testing.B) { 21 for i := 0; i < b.N; i++ { 22 timer.Add(ctx, time.Hour, func(ctx context.Context) { 23 24 }) 25 } 26 } 27 28 func Benchmark_PriorityQueue_Pop(b *testing.B) { 29 for i := 0; i < b.N; i++ { 30 timer.queue.Pop() 31 } 32 } 33 34 func Benchmark_StartStop(b *testing.B) { 35 for i := 0; i < b.N; i++ { 36 timer.Start() 37 timer.Stop() 38 } 39 }