1 Star 0 Fork 63

神以灵丶/carbon

forked from dromara/carbon 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
extremum_bench_test.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
gouguoyin 提交于 2024-01-12 10:57 . v2.3.5
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())
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/latke/carbon.git
git@gitee.com:latke/carbon.git
latke
carbon
carbon
master

搜索帮助