mirror of
https://github.com/americanexpress/baton.git
synced 2025-07-08 05:12:30 +00:00
38 lines
638 B
Go
38 lines
638 B
Go
package fasthttp
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func BenchmarkCoarseTimeNow(b *testing.B) {
|
|
var zeroTimeCount uint64
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
for pb.Next() {
|
|
t := CoarseTimeNow()
|
|
if t.IsZero() {
|
|
atomic.AddUint64(&zeroTimeCount, 1)
|
|
}
|
|
}
|
|
})
|
|
if zeroTimeCount > 0 {
|
|
b.Fatalf("zeroTimeCount must be zero")
|
|
}
|
|
}
|
|
|
|
func BenchmarkTimeNow(b *testing.B) {
|
|
var zeroTimeCount uint64
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
for pb.Next() {
|
|
t := time.Now()
|
|
if t.IsZero() {
|
|
atomic.AddUint64(&zeroTimeCount, 1)
|
|
}
|
|
}
|
|
})
|
|
if zeroTimeCount > 0 {
|
|
b.Fatalf("zeroTimeCount must be zero")
|
|
}
|
|
}
|