1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Silence assert_slower_by_at_most by default

Tests shouldn't have any output if they pass.
This commit is contained in:
Jean Boussier 2021-04-27 09:34:41 +02:00
parent 4c91c7f2e1
commit ed8667df5c

View file

@ -112,7 +112,7 @@ module ActiveRecord::Encryption
# assert_slower_by_at_most 2, baseline: baseline do
# <the code you want to compare against the baseline>
# end
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)
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)
GC.start
result = nil
@ -125,13 +125,15 @@ module ActiveRecord::Encryption
end
end
puts "#{output}#{error}" unless quiet
baseline_result = result.entries.find { |entry| entry.label == baseline_label }
code_to_test_result = result.entries.find { |entry| entry.label == code_to_test_label }
times_slower = baseline_result.ips / code_to_test_result.ips
if !quiet || times_slower >= threshold_factor
puts "#{output}#{error}"
end
assert times_slower < threshold_factor, "Expecting #{threshold_factor} times slower at most, but got #{times_slower} times slower"
end
end