加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
extremum_bench_test.go 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
package carbon
import "testing"
func BenchmarkCarbon_Closest(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Closest(Yesterday(), Yesterday().AddDay())
}
for n := 0; n < b.N; n++ {
now.Closest(Yesterday().AddDay(), Yesterday())
}
for n := 0; n < b.N; n++ {
now.Closest(Parse("xxx"), Parse("2022-08-05"))
}
for n := 0; n < b.N; n++ {
now.Closest(Parse("2020-08-05"), Parse("xxx"))
}
}
func BenchmarkCarbon_Farthest(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
now.Farthest(now.AddYear(), Yesterday())
}
for n := 0; n < b.N; n++ {
now.Farthest(Yesterday(), now.AddYear())
}
for n := 0; n < b.N; n++ {
now.Farthest(Parse("xxx"), Parse("2022-08-05"))
}
for n := 0; n < b.N; n++ {
now.Farthest(Parse("2020-08-05"), Parse("xxx"))
}
}
func BenchmarkCarbon_Max(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
Max(now.SubDay(), now.AddDay())
}
}
func BenchmarkCarbon_Min(b *testing.B) {
now := Now()
for n := 0; n < b.N; n++ {
Min(now.SubDay(), now.AddDay())
}
}
func BenchmarkCarbon_MaxCarbon(b *testing.B) {
for n := 0; n < b.N; n++ {
MaxCarbon()
}
}
func BenchmarkCarbon_MinCarbon(b *testing.B) {
for n := 0; n < b.N; n++ {
MinCarbon()
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化