mirror of
https://gitee.com/dromara/carbon.git
synced 2024-12-02 04:07:36 +08:00
提高性能测试覆盖率
This commit is contained in:
parent
42af04c183
commit
3b1a66176e
@ -5,7 +5,10 @@ import "testing"
|
|||||||
func BenchmarkCarbon_Closest(b *testing.B) {
|
func BenchmarkCarbon_Closest(b *testing.B) {
|
||||||
now := Now()
|
now := Now()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
now.Closest(Parse("2020-08-05"), Parse("2022-08-05"))
|
now.Closest(Yesterday(), Yesterday().AddDay())
|
||||||
|
}
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
now.Closest(Yesterday().AddDay(), Yesterday())
|
||||||
}
|
}
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
now.Closest(Parse("xxx"), Parse("2022-08-05"))
|
now.Closest(Parse("xxx"), Parse("2022-08-05"))
|
||||||
@ -18,7 +21,10 @@ func BenchmarkCarbon_Closest(b *testing.B) {
|
|||||||
func BenchmarkCarbon_Farthest(b *testing.B) {
|
func BenchmarkCarbon_Farthest(b *testing.B) {
|
||||||
now := Now()
|
now := Now()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
now.Farthest(Parse("2020-08-05"), Parse("2022-08-05"))
|
now.Farthest(now.AddYear(), Yesterday())
|
||||||
|
}
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
now.Farthest(Yesterday(), now.AddYear())
|
||||||
}
|
}
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
now.Farthest(Parse("xxx"), Parse("2022-08-05"))
|
now.Farthest(Parse("xxx"), Parse("2022-08-05"))
|
||||||
|
Loading…
Reference in New Issue
Block a user