Skip to content

Commit e35d1f1

Browse files
committed
[GR-34937] Fix core-string-equal benchmark to actually measure comparing bytes
PullRequest: truffleruby/3439
2 parents 78264ff + 6529fff commit e35d1f1

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

bench/micro/string/equal.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,27 @@ def str(n)
1313
Array.new(n, 'a'.ord).pack('C*')
1414
end
1515

16+
def are_equal?(a, b)
17+
a == b
18+
end
19+
1620
s1_small = str(small)
1721
s2_small = str(small)
1822

1923
s1_large = str(large)
2024
s2_large = str(large)
2125

22-
equal = s1_small == s2_small
23-
raise unless equal
24-
equal = s1_large == s2_large
25-
raise unless equal
26+
equal = false
27+
28+
[[s1_small, s2_small], [s1_large, s2_large]].each do |a, b|
29+
equal = are_equal?(a, b) # prevent splitting and identity caching
30+
raise unless equal
31+
end
2632

2733
benchmark "core-string-equal-#{small}" do
28-
equal = s1_small == s2_small
34+
equal = are_equal?(s1_small, s2_small)
2935
end
3036

3137
benchmark "core-string-equal-#{large}" do
32-
equal = s1_large == s2_large
38+
equal = are_equal?(s1_large, s2_large)
3339
end

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
692692
"ruby-benchmarks-warmup-svm-graal-enterprise-multi-tier": shared + warmup + svm_configurations["svm-graal-enterprise"] + $.use.multi_tier,
693693
"ruby-benchmarks-warmup-svm-graal-enterprise-multi-tier-3threads": shared + warmup + svm_configurations["svm-graal-enterprise"] + $.use.multi_tier + $.use.three_threads,
694694

695-
local micro = $.benchmark.runner + $.benchmark.micro + { timelimit: "01:00:00" },
695+
local micro = $.benchmark.runner + $.benchmark.micro + { timelimit: "01:30:00" },
696696
"ruby-benchmarks-micro-mri": shared + micro + other_rubies.mri,
697697
"ruby-benchmarks-micro-jruby": shared + micro + other_rubies.jruby,
698698
"ruby-benchmarks-micro-graal-core": shared + micro + graal_configurations["graal-core"] + $.use.no_multi_tier,

0 commit comments

Comments
 (0)