Skip to content

Commit 52889cd

Browse files
authored
Sort benchmark definitions alphabetically (#524)
1 parent d771f81 commit 52889cd

2 files changed

Lines changed: 55 additions & 32 deletions

File tree

benchmarks.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ rubyboy:
130130
ractor: true
131131
rubykon:
132132
desc: Ruby solver for Go (the boardgame.) Runs many iterations forward from an initial starting board.
133-
sudoku:
134-
desc: sudoku solver
135-
ractor: true
136133
splay:
137134
desc: Splay tree operations (insert, find, remove) to stress GC.
138135
single_file: true
136+
sudoku:
137+
desc: sudoku solver
138+
ractor: true
139139
string_malloc_pressure:
140140
desc: Allocates and retains many empty Strings with large reserved capacity to exercise GC under malloc-backed String buffer pressure.
141141
category: gc
@@ -166,18 +166,6 @@ cfunc_itself:
166166
desc: cfunc_itself just calls the 'itself' method many, many times.
167167
category: micro
168168
single_file: true
169-
send_cfunc_block:
170-
desc: send_cfunc_block just calls a known C function with a block many, many times.
171-
category: micro
172-
single_file: true
173-
send_rubyfunc_block:
174-
desc: send_rubyfunc_block just calls a known Ruby function with a block many, many times.
175-
category: micro
176-
single_file: true
177-
send_bmethod:
178-
desc: send_bmethod just calls known Ruby bmethods many, many times.
179-
category: micro
180-
single_file: true
181169
fib:
182170
desc: Fib is a simple exponential-time recursive Fibonacci number generator.
183171
category: micro
@@ -193,14 +181,6 @@ getivar-module:
193181
category: micro
194182
single_file: true
195183
ractor: true
196-
structaref:
197-
desc: structaref tests the performance of getting Struct members
198-
category: micro
199-
single_file: true
200-
structaset:
201-
desc: structaset tests the performance of setting Struct members
202-
category: micro
203-
single_file: true
204184
keyword_args:
205185
desc: keyword_args tests the performance of method calls with keyword arguments.
206186
category: micro
@@ -233,6 +213,22 @@ ruby-xor:
233213
category: micro
234214
single_file: true
235215
ractor: true
216+
send_bmethod:
217+
desc: send_bmethod just calls known Ruby bmethods many, many times.
218+
category: micro
219+
single_file: true
220+
send_cfunc_block:
221+
desc: send_cfunc_block just calls a known C function with a block many, many times.
222+
category: micro
223+
single_file: true
224+
send_rubyfunc_block:
225+
desc: send_rubyfunc_block just calls a known Ruby function with a block many, many times.
226+
category: micro
227+
single_file: true
228+
send_rubyfunc_inline:
229+
desc: send_rubyfunc_inline repeatedly calls a small inlinable Ruby method with multiple arguments.
230+
category: micro
231+
single_file: true
236232
setivar:
237233
desc: setivar tests the performance of setting instance variable values.
238234
category: micro
@@ -251,24 +247,23 @@ str_concat:
251247
category: micro
252248
single_file: true
253249
ractor: true
250+
structaref:
251+
desc: structaref tests the performance of getting Struct members
252+
category: micro
253+
single_file: true
254+
structaset:
255+
desc: structaset tests the performance of setting Struct members
256+
category: micro
257+
single_file: true
254258
throw:
255259
desc: microbenchmark for the throw instruction and stack unwinding.
256260
category: micro
257261
single_file: true
258262
ractor: true
259-
send_rubyfunc_inline:
260-
desc: send_rubyfunc_inline repeatedly calls a small inlinable Ruby method with multiple arguments.
261-
category: micro
262-
single_file: true
263263

264264
#
265265
# Ractor scaling benchmarks
266266
#
267-
symbol-name-ractor:
268-
desc: repeatedly calls Symbol#name on a static symbol under the ractor harness to stress ID-to-string lookup.
269-
ractor: true
270-
ractor_only: true
271-
default_harness: harness-ractor
272267
gvl_release_acquire:
273268
desc: microbenchmark designed to test how fast the gvl can be acquired and released between ractors.
274269
ractor: true
@@ -284,3 +279,8 @@ json_parse_string:
284279
ractor: true
285280
ractor_only: true
286281
default_harness: harness-ractor
282+
symbol-name-ractor:
283+
desc: repeatedly calls Symbol#name on a static symbol under the ractor harness to stress ID-to-string lookup.
284+
ractor: true
285+
ractor_only: true
286+
default_harness: harness-ractor

test/benchmarks_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,27 @@
2222

2323
assert_equal yml_keys, discovered_keys
2424
end
25+
26+
it 'sorts benchmarks alphabetically within each category' do
27+
yjit_bench = File.expand_path('..', __dir__)
28+
benchmarks_yml = YAML.load_file("#{yjit_bench}/benchmarks.yml")
29+
30+
benchmark_names_by_category = Hash.new { |hash, key| hash[key] = [] }
31+
benchmarks_yml.each do |name, metadata|
32+
category = metadata.fetch('category') do
33+
# Ractor scaling benchmarks are intentionally kept in their own section.
34+
metadata['default_harness'] == 'harness-ractor' ? 'ractor-scaling' : 'other'
35+
end
36+
benchmark_names_by_category[category] << name
37+
end
38+
39+
benchmark_names_by_category.each do |category, benchmark_names|
40+
assert_equal format_benchmark_names(benchmark_names.sort), format_benchmark_names(benchmark_names),
41+
"#{category} benchmarks should be sorted alphabetically"
42+
end
43+
end
44+
45+
def format_benchmark_names(benchmark_names)
46+
"[\n#{benchmark_names.map { |name| " #{name.inspect}," }.join("\n")}\n]\n"
47+
end
2548
end

0 commit comments

Comments
 (0)