File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919task :test_option do
2020 sh "go test -cover -v ./option"
2121end
22+
23+ task :e2e do
24+ sh "go test -cover -v ./e2e"
25+ end
26+
27+ task :bench do
28+ sh "go test -bench=. -benchmem -cpu='1,2,4'"
29+ end
Original file line number Diff line number Diff line change 1+ package bench_test
2+
3+ import (
4+ "testing"
5+
6+ . "github.com/initdc/types/option"
7+ . "github.com/initdc/types/result"
8+ )
9+
10+ func BenchmarkOptionSome (b * testing.B ) {
11+ b .ResetTimer ()
12+ b .StartTimer ()
13+
14+ for i := 0 ; i < b .N ; i ++ {
15+ var o Option [int32 ]
16+ o .Some (0 )
17+ }
18+
19+ b .StopTimer ()
20+ }
21+
22+ func BenchmarkOptionNone (b * testing.B ) {
23+ b .ResetTimer ()
24+ b .StartTimer ()
25+
26+ for i := 0 ; i < b .N ; i ++ {
27+ var o Option [int32 ]
28+ o .None ()
29+ }
30+
31+ b .StopTimer ()
32+ }
33+
34+ func BenchmarkSome (b * testing.B ) {
35+ b .ResetTimer ()
36+ b .StartTimer ()
37+
38+ for i := 0 ; i < b .N ; i ++ {
39+ Some [int32 ](0 )
40+ }
41+
42+ b .StopTimer ()
43+ }
44+
45+ func BenchmarkNone (b * testing.B ) {
46+ b .ResetTimer ()
47+ b .StartTimer ()
48+
49+ for i := 0 ; i < b .N ; i ++ {
50+ None [int32 ]()
51+ }
52+
53+ b .StopTimer ()
54+ }
55+
56+ func BenchmarkResultOk (b * testing.B ) {
57+ b .ResetTimer ()
58+ b .StartTimer ()
59+
60+ for i := 0 ; i < b .N ; i ++ {
61+
62+ var r Result [int32 , int32 ]
63+ r .Ok (0 )
64+ }
65+
66+ b .StopTimer ()
67+ }
68+
69+ func BenchmarkResultErr (b * testing.B ) {
70+ b .ResetTimer ()
71+ b .StartTimer ()
72+
73+ for i := 0 ; i < b .N ; i ++ {
74+
75+ var r Result [int32 , int32 ]
76+ r .Err (0 )
77+ }
78+
79+ b .StopTimer ()
80+ }
81+
82+ func BenchmarkOk (b * testing.B ) {
83+ b .ResetTimer ()
84+ b .StartTimer ()
85+
86+ for i := 0 ; i < b .N ; i ++ {
87+ Ok [int32 , int32 ](0 )
88+ }
89+
90+ b .StopTimer ()
91+ }
92+
93+ func BenchmarkErr (b * testing.B ) {
94+ b .ResetTimer ()
95+ b .StartTimer ()
96+
97+ for i := 0 ; i < b .N ; i ++ {
98+ Err [int32 , int32 ](0 )
99+ }
100+
101+ b .StopTimer ()
102+ }
File renamed without changes.
You can’t perform that action at this time.
0 commit comments