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:
parent
4c91c7f2e1
commit
ed8667df5c
1 changed files with 5 additions and 3 deletions
|
@ -112,7 +112,7 @@ module ActiveRecord::Encryption
|
||||||
# assert_slower_by_at_most 2, baseline: baseline do
|
# assert_slower_by_at_most 2, baseline: baseline do
|
||||||
# <the code you want to compare against the baseline>
|
# <the code you want to compare against the baseline>
|
||||||
# end
|
# 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
|
GC.start
|
||||||
|
|
||||||
result = nil
|
result = nil
|
||||||
|
@ -125,13 +125,15 @@ module ActiveRecord::Encryption
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "#{output}#{error}" unless quiet
|
|
||||||
|
|
||||||
baseline_result = result.entries.find { |entry| entry.label == baseline_label }
|
baseline_result = result.entries.find { |entry| entry.label == baseline_label }
|
||||||
code_to_test_result = result.entries.find { |entry| entry.label == code_to_test_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
|
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"
|
assert times_slower < threshold_factor, "Expecting #{threshold_factor} times slower at most, but got #{times_slower} times slower"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue