Skip to content

Commit cb9aea0

Browse files
andrykonchineregon
authored andcommitted
[GR-51466] Fix Hash micro menchmarks
PullRequest: truffleruby/4196
2 parents e97707f + 610ef86 commit cb9aea0

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

bench/benchmark-interface/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Supported backends are:
160160
#### Simple looping
161161

162162
Simple looping does the simplest thing possible and runs your benchmark in a
163-
loop printing the iterations per second as it goes. By default it runs for
163+
loop printing the iterations per second as it goes. By default, it runs for
164164
10s, printing the time every second, but you can use options like `--time 60`
165165
to run for 60 seconds, and `--freq 0.1` to print ten times a second.
166166

@@ -170,7 +170,7 @@ and the elapsed time since the benchmark started with the `--elapsed` flag.
170170
#### `bm` and `bmbm`
171171

172172
`bm` and `bmbm` only run your benchmark once when timing, which isn't what
173-
benchmarks written for `benchmark-ips` expect. Therefore if a benchmark takes
173+
benchmarks written for `benchmark-ips` expect. Therefore, if a benchmark takes
174174
less than a tenth of a second it is run several times so that it takes about a
175175
second. The number of iterations is the same for all benchmarks in the same set
176176
and is printed as the set starts.

bench/micro/hash/buckets-lookup.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010

1111
# Benchmarks looking up keys
1212

13-
max = 400_000 # > 0.75*(524288 + 21) (cf. BucketsHashStore)
14-
hash = { a: 1, b: 2, c: 3, d: 4 } # big enough to start as a bucket hash
15-
max.times { |i|
16-
hash[i] = i
17-
}
13+
if RUBY_ENGINE == 'truffleruby'
14+
max = 400_000 # > 0.75*(524288 + 21) (cf. BucketsHashStore)
15+
hash = { a: 1, b: 2, c: 3, d: 4 } # big enough to start as a bucket hash
16+
max.times { |i|
17+
hash[i] = i
18+
}
1819

19-
benchmark 'core-hash-buckets-lookup' do
20-
1000.times do |i|
21-
Primitive.blackhole(hash[i])
20+
benchmark 'core-hash-buckets-lookup' do
21+
1000.times do |i|
22+
Primitive.blackhole(hash[i])
23+
end
2224
end
2325
end

0 commit comments

Comments
 (0)