baton/vendor/github.com/valyala/fasthttp/coarseTime_test.go
2018-02-16 14:50:36 -07:00

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")
}
}