Skip to content

Commit 3e7ba58

Browse files
committed
Delete EncryptionPerformanceTest
On my machine, running the whole Active Record test suite takes `88` seconds, and `40` of these are spent in encryption tests. Some of them also happen to flake because of random blips. I appreciate the care that has been put into ensuring the overhead of encrption was reasonable, but I don't think these tests justify their cost.
1 parent ed2e77d commit 3e7ba58

File tree

7 files changed

+1
-233
lines changed

7 files changed

+1
-233
lines changed

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ group :test do
143143
gem "debug", ">= 1.1.0", require: false
144144
end
145145

146-
gem "benchmark-ips"
147-
148146
# Needed for Railties tests because it is included in generated apps.
149147
gem "brakeman"
150148
end

Gemfile.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ GEM
159159
base64 (0.2.0)
160160
bcrypt (3.1.20)
161161
beaneater (1.1.3)
162-
benchmark-ips (2.13.0)
163162
bigdecimal (3.1.5)
164163
bindex (0.8.1)
165164
bootsnap (1.17.0)
@@ -596,7 +595,6 @@ DEPENDENCIES
596595
azure-storage-blob (~> 2.0)
597596
backburner
598597
bcrypt (~> 3.1.11)
599-
benchmark-ips
600598
bootsnap (>= 1.4.4)
601599
brakeman
602600
capybara (>= 3.39)

activerecord/test/cases/encryption/helper.rb

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require "cases/helper"
4-
require "benchmark/ips"
54

65
class ActiveRecord::Fixture
76
prepend ActiveRecord::Encryption::EncryptedFixtures
@@ -111,45 +110,6 @@ def assert_invalid_key_cant_read_attribute_with_custom_key_provider(model, attri
111110
attribute_type.key_provider.keys = original_keys
112111
end
113112
end
114-
115-
module PerformanceHelpers
116-
BENCHMARK_DURATION = 1
117-
BENCHMARK_WARMUP = 1
118-
BASELINE_LABEL = "Baseline"
119-
CODE_TO_TEST_LABEL = "Code"
120-
121-
# Usage:
122-
#
123-
# baseline = -> { <some baseline code> }
124-
#
125-
# assert_slower_by_at_most 2, baseline: baseline do
126-
# <the code you want to compare against the baseline>
127-
# end
128-
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)
129-
GC.start
130-
131-
result = nil
132-
output, error = capture_io do
133-
result = Benchmark.ips do |x|
134-
x.config(time: duration, warmup: BENCHMARK_WARMUP)
135-
x.report(code_to_test_label, &block_to_test)
136-
x.report(baseline_label, &baseline)
137-
x.compare!
138-
end
139-
end
140-
141-
baseline_result = result.entries.find { |entry| entry.label == baseline_label }
142-
code_to_test_result = result.entries.find { |entry| entry.label == code_to_test_label }
143-
144-
times_slower = baseline_result.ips / code_to_test_result.ips
145-
146-
if !quiet || times_slower >= threshold_factor
147-
puts "#{output}#{error}"
148-
end
149-
150-
assert times_slower < threshold_factor, "Expecting #{threshold_factor} times slower at most, but got #{times_slower} times slower"
151-
end
152-
end
153113
end
154114

155115
# We eager load encrypted attribute types as they are declared, so that they pick up the
@@ -163,7 +123,7 @@ def assert_slower_by_at_most(threshold_factor, baseline:, baseline_label: BASELI
163123
end
164124

165125
class ActiveRecord::EncryptionTestCase < ActiveRecord::TestCase
166-
include ActiveRecord::Encryption::EncryptionHelpers, ActiveRecord::Encryption::PerformanceHelpers
126+
include ActiveRecord::Encryption::EncryptionHelpers
167127

168128
ENCRYPTION_PROPERTIES_TO_RESET = {
169129
config: %i[ primary_key deterministic_key key_derivation_salt store_key_references hash_digest_class

activerecord/test/cases/encryption/performance/encryption_performance_test.rb

Lines changed: 0 additions & 42 deletions
This file was deleted.

activerecord/test/cases/encryption/performance/envelope_encryption_performance_test.rb

Lines changed: 0 additions & 53 deletions
This file was deleted.

activerecord/test/cases/encryption/performance/extended_deterministic_queries_performance_test.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

activerecord/test/cases/encryption/performance/storage_performance_test.rb

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)