-
-
Notifications
You must be signed in to change notification settings - Fork 244
/
extremum_bench_test.go
executable file
·61 lines (54 loc) · 1.19 KB
/
extremum_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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_MaxValue(b *testing.B) {
for n := 0; n < b.N; n++ {
MaxValue()
}
}
func BenchmarkCarbon_MinValue(b *testing.B) {
for n := 0; n < b.N; n++ {
MinValue()
}
}