Skip to content

Commit 2782a66

Browse files
author
Kurtis Rainbolt-Greene
committed
We want the benchmarks to conform to the rubocop style
1 parent 7b8bc11 commit 2782a66

File tree

5 files changed

+35
-46
lines changed

5 files changed

+35
-46
lines changed

bench/hash/each_bench.rb

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
# gem install benchmark_suite
2-
require 'benchmark/ips'
3-
4-
require 'hamster/hash'
1+
require "benchmark/ips"
2+
require "hamster/hash"
53

64
Benchmark.ips do |b|
75
sml_hash = Hamster.hash(1 => 1)
86
med_hash = Hamster.hash
9-
1_000.times {|i| med_hash = med_hash.put(i, i)}
7+
1_000.times { |i| med_hash = med_hash.put(i, i) }
108
lrg_hash = Hamster.hash
11-
1_000_000.times {|i| lrg_hash = lrg_hash.put(i, i)}
12-
9+
1_000_000.times { |i| lrg_hash = lrg_hash.put(i, i) }
10+
1311
b.report "each small" do |n|
1412
a = 0
1513
x = 0
1614
while a < n
17-
sml_hash.each {|y| x = y}
15+
sml_hash.each { |y| x = y }
1816
a += 1
1917
end
2018
end
21-
19+
2220
b.report "each medium" do |n|
2321
a = 0
2422
x = 0
2523
while a < n
26-
med_hash.each {|y| x = y}
24+
med_hash.each { |y| x = y }
2725
a += 1
2826
end
2927
end
30-
28+
3129
b.report "each large" do |n|
3230
a = 0
3331
x = 0
3432
while a < n
35-
lrg_hash.each {|y| x = y}
33+
lrg_hash.each { |y| x = y }
3634
a += 1
3735
end
3836
end
39-
end
37+
end

bench/hash/get_bench.rb

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# gem install benchmark_suite
2-
require 'benchmark/ips'
1+
require "benchmark/ips"
32

4-
require 'hamster/hash'
3+
require "hamster/hash"
54

65
Benchmark.ips do |b|
76
sml_hash = Hamster.hash(1 => 1)
87
med_hash = Hamster.hash
9-
1_000.times {|i| med_hash = med_hash.put(i, i)}
8+
1_000.times { |i| med_hash = med_hash.put(i, i) }
109
lrg_hash = Hamster.hash
11-
1_000_000.times {|i| lrg_hash = lrg_hash.put(i, i)}
12-
10+
1_000_000.times { |i| lrg_hash = lrg_hash.put(i, i) }
11+
1312
b.report "get existing small" do |n|
1413
a = 0
1514
x = 0
@@ -18,7 +17,7 @@
1817
a += 1
1918
end
2019
end
21-
20+
2221
b.report "get existing medium" do |n|
2322
a = 0
2423
x = nil
@@ -27,7 +26,7 @@
2726
a += 1
2827
end
2928
end
30-
29+
3130
b.report "get existing large" do |n|
3231
a = 0
3332
x = nil
@@ -36,7 +35,7 @@
3635
a += 1
3736
end
3837
end
39-
38+
4039
b.report "get missing small" do |n|
4140
a = 0
4241
x = 0
@@ -45,7 +44,7 @@
4544
a += 1
4645
end
4746
end
48-
47+
4948
b.report "get existing medium" do |n|
5049
a = 0
5150
x = nil
@@ -54,7 +53,7 @@
5453
a += 1
5554
end
5655
end
57-
56+
5857
b.report "get existing large" do |n|
5958
a = 0
6059
x = nil
@@ -64,4 +63,3 @@
6463
end
6564
end
6665
end
67-

bench/hash/put_bench.rb

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# gem install benchmark_suite
2-
require 'benchmark/ips'
3-
4-
require 'hamster/hash'
1+
require "benchmark/ips"
2+
require "hamster/hash"
53

64
Benchmark.ips do |b|
75
sml_hash = Hamster.hash(1 => 1)
86
med_hash = Hamster.hash
9-
1_000.times {|i| med_hash = med_hash.put(i, i)}
7+
1_000.times { |i| med_hash = med_hash.put(i, i) }
108
lrg_hash = Hamster.hash
11-
1_000_000.times {|i| lrg_hash = lrg_hash.put(i, i)}
9+
1_000_000.times { |i| lrg_hash = lrg_hash.put(i, i) }
1210

1311
b.report "put value" do |n|
1412
a = 0
@@ -18,7 +16,7 @@
1816
a += 1
1917
end
2018
end
21-
19+
2220
b.report "put value medium" do |n|
2321
a = 0
2422
med = med_hash
@@ -27,7 +25,7 @@
2725
a += 1
2826
end
2927
end
30-
28+
3129
b.report "put value large" do |n|
3230
a = 0
3331
lrg = lrg_hash
@@ -37,4 +35,3 @@
3735
end
3836
end
3937
end
40-

bench/list/at_bench.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
# gem install benchmark_suite
2-
require 'benchmark/ips'
3-
4-
require 'hamster/list'
1+
require "benchmark/ips"
2+
require "hamster/list"
53

64
Benchmark.ips do |b|
75
sml_list = Hamster.list(1)
86
# med_list = Hamster.iterate(1, &:next).take(100)
97
# lrg_list = Hamster.iterate(1, &:next).take(10000)
108
med_list = Hamster.list
11-
100.times {|i| med_list = med_list.cons(i)}
9+
100.times { |i| med_list = med_list.cons(i) }
1210
lrg_list = Hamster.list
13-
10000.times {|i| lrg_list = lrg_list.cons(i)}
11+
10000.times { |i| lrg_list = lrg_list.cons(i) }
1412

1513
b.report "at small" do |n|
1614
a = 0

bench/list/cons_bench.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# gem install benchmark_suite
2-
require 'benchmark/ips'
3-
4-
require 'hamster/list'
1+
require "benchmark/ips"
2+
require "hamster/list"
53

64
Benchmark.ips do |b|
75
sml_list = Hamster.list(1)
86
med_list = Hamster.list
9-
100.times {|i| med_list = med_list.cons(i)}
7+
100.times { |i| med_list = med_list.cons(i) }
108
lrg_list = Hamster.list
11-
10000.times {|i| lrg_list = lrg_list.cons(i)}
9+
10000.times { |i| lrg_list = lrg_list.cons(i) }
1210

1311
b.report "cons small" do |n|
1412
a = 0

0 commit comments

Comments
 (0)