File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed
Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ require " benchmark"
2+ require " ./src/types"
3+
4+ n = 1000
5+
6+ calculation = 1 .seconds
7+ warmup = 2 .seconds
8+
9+ Benchmark .ips(calculation, warmup) do |x |
10+ x.report(" Some()" ) do
11+ n.times do
12+ Some (Int32 )[0 ]
13+ end
14+ end
15+
16+ x.report(" Some.new" ) do
17+ n.times do
18+ Some .new(0 )
19+ end
20+ end
21+
22+ x.report(" None()" ) do
23+ n.times do
24+ None (Int32 )[]
25+ end
26+ end
27+
28+ x.report(" None.new" ) do
29+ n.times do
30+ None (Int32 ).new
31+ end
32+ end
33+ end
34+
35+ Benchmark .ips(calculation, warmup) do |x |
36+ x.report(" Ok()" ) do
37+ n.times do
38+ Ok (Int32 , Int32 )[0 ]
39+ end
40+ end
41+
42+ x.report(" Ok.new" ) do
43+ n.times do
44+ Ok (Int32 , Int32 ).new(0 )
45+ end
46+ end
47+
48+ x.report(" Err()" ) do
49+ n.times do
50+ Err (Int32 , Int32 )[0 ]
51+ end
52+ end
53+
54+ x.report(" Err.new" ) do
55+ n.times do
56+ Err (Int32 , Int32 ).new(0 )
57+ end
58+ end
59+ end
You can’t perform that action at this time.
0 commit comments