Skip to content

Commit ed8667d

Browse files
committed
Silence assert_slower_by_at_most by default
Tests shouldn't have any output if they pass.
1 parent 4c91c7f commit ed8667d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

activerecord/test/cases/encryption/helper.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module PerformanceHelpers
112112
# assert_slower_by_at_most 2, baseline: baseline do
113113
# <the code you want to compare against the baseline>
114114
# end
115-
def assert_slower_by_at_most(threshold_factor, baseline:, baseline_label: BASELINE_LABEL, code_to_test_label: CODE_TO_TEST_LABEL, duration: BENCHMARK_DURATION, quiet: false, &block_to_test)
115+
def assert_slower_by_at_most(threshold_factor, baseline:, baseline_label: BASELINE_LABEL, code_to_test_label: CODE_TO_TEST_LABEL, duration: BENCHMARK_DURATION, quiet: true, &block_to_test)
116116
GC.start
117117

118118
result = nil
@@ -125,13 +125,15 @@ def assert_slower_by_at_most(threshold_factor, baseline:, baseline_label: BASELI
125125
end
126126
end
127127

128-
puts "#{output}#{error}" unless quiet
129-
130128
baseline_result = result.entries.find { |entry| entry.label == baseline_label }
131129
code_to_test_result = result.entries.find { |entry| entry.label == code_to_test_label }
132130

133131
times_slower = baseline_result.ips / code_to_test_result.ips
134132

133+
if !quiet || times_slower >= threshold_factor
134+
puts "#{output}#{error}"
135+
end
136+
135137
assert times_slower < threshold_factor, "Expecting #{threshold_factor} times slower at most, but got #{times_slower} times slower"
136138
end
137139
end

0 commit comments

Comments
 (0)