Skip to content

Commit 0b7b37b

Browse files
committed
Move base_name and other_names extraction into build_output_text
1 parent 5aeda13 commit 0b7b37b

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

lib/benchmark_runner.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ def write_csv(output_path, ruby_descriptions, table)
4848
end
4949

5050
# Build output text string with metadata, table, and legend
51-
def build_output_text(ruby_descriptions, table, format, bench_failures, base_name, other_names)
51+
def build_output_text(ruby_descriptions, table, format, bench_failures)
52+
base_name, *other_names = ruby_descriptions.keys
53+
5254
output_str = +""
5355

5456
ruby_descriptions.each do |key, value|

run_benchmarks.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757

5858
# Build results table
5959
all_names = args.executables.keys
60-
base_name, *other_names = all_names
6160
builder = ResultsTableBuilder.new(
6261
executable_names: all_names,
6362
bench_data: bench_data,
@@ -76,7 +75,7 @@
7675
BenchmarkRunner.write_csv(output_path, ruby_descriptions, table)
7776

7877
# Save the output in a text file that we can easily refer to
79-
output_str = BenchmarkRunner.build_output_text(ruby_descriptions, table, format, bench_failures, base_name, other_names)
78+
output_str = BenchmarkRunner.build_output_text(ruby_descriptions, table, format, bench_failures)
8079
out_txt_path = output_path + ".txt"
8180
File.open(out_txt_path, "w") { |f| f.write output_str }
8281

test/benchmark_runner_test.rb

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,9 @@
377377
]
378378
format = ['%s', '%.1f', '%.1f', '%.1f', '%.1f']
379379
bench_failures = {}
380-
base_name = 'ruby-base'
381-
other_names = ['ruby-yjit']
382380

383381
result = BenchmarkRunner.build_output_text(
384-
ruby_descriptions, table, format, bench_failures, base_name, other_names
382+
ruby_descriptions, table, format, bench_failures
385383
)
386384

387385
assert_includes result, 'ruby-base: ruby 3.3.0'
@@ -399,11 +397,9 @@
399397
]
400398
format = ['%s', '%.1f', '%.1f']
401399
bench_failures = {}
402-
base_name = 'ruby'
403-
other_names = []
404400

405401
result = BenchmarkRunner.build_output_text(
406-
ruby_descriptions, table, format, bench_failures, base_name, other_names
402+
ruby_descriptions, table, format, bench_failures
407403
)
408404

409405
# Should contain table headers
@@ -419,11 +415,9 @@
419415
table = [['bench', 'ruby (ms)'], ['fib', '100.0']]
420416
format = ['%s', '%.1f']
421417
bench_failures = {}
422-
base_name = 'ruby'
423-
other_names = []
424418

425419
result = BenchmarkRunner.build_output_text(
426-
ruby_descriptions, table, format, bench_failures, base_name, other_names
420+
ruby_descriptions, table, format, bench_failures
427421
)
428422

429423
refute_includes result, 'Legend:'
@@ -438,11 +432,9 @@
438432
table = [['bench', 'ruby (ms)', 'ruby-yjit (ms)', 'ruby-rjit (ms)']]
439433
format = ['%s', '%.1f', '%.1f', '%.1f']
440434
bench_failures = {}
441-
base_name = 'ruby'
442-
other_names = ['ruby-yjit', 'ruby-rjit']
443435

444436
result = BenchmarkRunner.build_output_text(
445-
ruby_descriptions, table, format, bench_failures, base_name, other_names
437+
ruby_descriptions, table, format, bench_failures
446438
)
447439

448440
assert_includes result, 'ruby-yjit 1st itr'
@@ -458,11 +450,9 @@
458450
bench_failures = {
459451
'ruby' => { 'failed_bench' => 'error message' }
460452
}
461-
base_name = 'ruby'
462-
other_names = []
463453

464454
result = BenchmarkRunner.build_output_text(
465-
ruby_descriptions, table, format, bench_failures, base_name, other_names
455+
ruby_descriptions, table, format, bench_failures
466456
)
467457

468458
# TableFormatter handles displaying failures, just verify it's called
@@ -475,11 +465,9 @@
475465
table = [['bench']]
476466
format = ['%s']
477467
bench_failures = {}
478-
base_name = 'ruby'
479-
other_names = []
480468

481469
result = BenchmarkRunner.build_output_text(
482-
ruby_descriptions, table, format, bench_failures, base_name, other_names
470+
ruby_descriptions, table, format, bench_failures
483471
)
484472

485473
assert_kind_of String, result
@@ -495,11 +483,9 @@
495483
table = [['bench']]
496484
format = ['%s']
497485
bench_failures = {}
498-
base_name = 'ruby-a'
499-
other_names = []
500486

501487
result = BenchmarkRunner.build_output_text(
502-
ruby_descriptions, table, format, bench_failures, base_name, other_names
488+
ruby_descriptions, table, format, bench_failures
503489
)
504490

505491
lines = result.lines

0 commit comments

Comments
 (0)