32 lines
493 B
Go
32 lines
493 B
Go
|
|
package time_test
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
utime "apigo.cc/go/time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func BenchmarkParse(b *testing.B) {
|
||
|
|
input := "2025-06-23 15:30:45"
|
||
|
|
for i := 0; i < b.N; i++ {
|
||
|
|
_ = utime.Parse(input)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func BenchmarkFormat(b *testing.B) {
|
||
|
|
tm := time.Now()
|
||
|
|
layout := "YYYY-MM-DD HH:mm:ss"
|
||
|
|
for i := 0; i < b.N; i++ {
|
||
|
|
_ = utime.Format(layout, tm)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func BenchmarkAdd(b *testing.B) {
|
||
|
|
tm := time.Now()
|
||
|
|
expr := "+1Y2M3D4h5m6s"
|
||
|
|
for i := 0; i < b.N; i++ {
|
||
|
|
_ = utime.Add(expr, tm)
|
||
|
|
}
|
||
|
|
}
|