diff --git a/lib/benchmark/append_no_fail_if.rb b/lib/benchmark/append_no_fail_if.rb index e355200..d088f66 100644 --- a/lib/benchmark/append_no_fail_if.rb +++ b/lib/benchmark/append_no_fail_if.rb @@ -21,8 +21,6 @@ module En57 measure.call { @event_store.append(events) } end - - verify { @event_store.read.each.to_a.size == total_runs * @batch_size } end end end diff --git a/lib/benchmark/append_non_conflicting_tags.rb b/lib/benchmark/append_non_conflicting_tags.rb index d57c94d..402e01e 100644 --- a/lib/benchmark/append_non_conflicting_tags.rb +++ b/lib/benchmark/append_non_conflicting_tags.rb @@ -29,8 +29,6 @@ module En57 end end end - - verify { @event_store.read.each.to_a.size == total_runs * @batch_size } end end end diff --git a/lib/benchmark/concurrent_append_conflicting_tags.rb b/lib/benchmark/concurrent_append_conflicting_tags.rb index d939d76..8bf9a51 100644 --- a/lib/benchmark/concurrent_append_conflicting_tags.rb +++ b/lib/benchmark/concurrent_append_conflicting_tags.rb @@ -38,11 +38,6 @@ module En57 end end end - - verify do - @event_store.read.each.to_a.size == - total_runs * @concurrency * @batch_size - end end end end diff --git a/lib/benchmark/concurrent_append_no_fail_if.rb b/lib/benchmark/concurrent_append_no_fail_if.rb index f399652..34a88c3 100644 --- a/lib/benchmark/concurrent_append_no_fail_if.rb +++ b/lib/benchmark/concurrent_append_no_fail_if.rb @@ -26,11 +26,6 @@ module En57 measure.call { @event_store.append(events) } end end - - verify do - @event_store.read.each.to_a.size == - total_runs * @concurrency * @batch_size - end end end end diff --git a/lib/benchmark/concurrent_append_non_conflicting_tags.rb b/lib/benchmark/concurrent_append_non_conflicting_tags.rb index 4751dad..4d5a247 100644 --- a/lib/benchmark/concurrent_append_non_conflicting_tags.rb +++ b/lib/benchmark/concurrent_append_non_conflicting_tags.rb @@ -34,11 +34,6 @@ module En57 end end end - - verify do - @event_store.read.each.to_a.size == - total_runs * @concurrency * @batch_size - end end end end diff --git a/lib/benchmark/concurrent_append_non_conflicting_tags_seeded.rb b/lib/benchmark/concurrent_append_non_conflicting_tags_seeded.rb index 99ad11b..8d40b26 100644 --- a/lib/benchmark/concurrent_append_non_conflicting_tags_seeded.rb +++ b/lib/benchmark/concurrent_append_non_conflicting_tags_seeded.rb @@ -34,11 +34,6 @@ module En57 end end end - - verify do - @event_store.read.each.to_a.size == - 1_000_000 + total_runs * @concurrency * @batch_size - end end end end diff --git a/lib/benchmark/res_append_stream_any.rb b/lib/benchmark/res_append_stream_any.rb index 3d32067..d0b31e2 100644 --- a/lib/benchmark/res_append_stream_any.rb +++ b/lib/benchmark/res_append_stream_any.rb @@ -29,8 +29,6 @@ module En57 @event_store.append(events, stream_name: tag, expected_version: :any) end end - - verify { @event_store.read.each.to_a.size == total_runs * @batch_size } end end end diff --git a/lib/benchmark/res_concurrent_append_conflicting_streams.rb b/lib/benchmark/res_concurrent_append_conflicting_streams.rb index 5c40af3..af86bbc 100644 --- a/lib/benchmark/res_concurrent_append_conflicting_streams.rb +++ b/lib/benchmark/res_concurrent_append_conflicting_streams.rb @@ -45,11 +45,6 @@ module En57 end end end - - verify do - @event_store.read.each.to_a.size == - total_runs * @concurrency * @batch_size - end end end end diff --git a/lib/benchmark/res_concurrent_append_non_conflicting_streams.rb b/lib/benchmark/res_concurrent_append_non_conflicting_streams.rb index c889a0c..f9d7e14 100644 --- a/lib/benchmark/res_concurrent_append_non_conflicting_streams.rb +++ b/lib/benchmark/res_concurrent_append_non_conflicting_streams.rb @@ -39,11 +39,6 @@ module En57 end end end - - verify do - @event_store.read.each.to_a.size == - total_runs * @concurrency * @batch_size - end end end end diff --git a/lib/en57/benchmark.rb b/lib/en57/benchmark.rb index 8e4aaf1..20bde1f 100644 --- a/lib/en57/benchmark.rb +++ b/lib/en57/benchmark.rb @@ -19,13 +19,11 @@ module En57 :max, :median, :retry_count, - :verified, ) class Table def format(results) - rows = results.select(&:verified) - return "" if rows.empty? + return "" if results.empty? header = [ "Scenario", @@ -38,7 +36,7 @@ module En57 "Retries", ] body = - rows.map do |result| + results.map do |result| [ result.name, result.runs.to_s, @@ -129,7 +127,6 @@ module En57 :batch_size, :setup, :call_block, - :verify, ) class ScenarioDSL @@ -139,7 +136,6 @@ module En57 @batch_size = 100 @setup = ->(_database_url) {} @call_block = ->(_measure) {} - @verify = -> { true } end def database_instance(value) = @database_instance = value @@ -150,7 +146,6 @@ module En57 def batch_size(value) = @batch_size = value def setup(&block) = @setup = block def call(&block) = @call_block = block - def verify(&block) = @verify = block def definition ScenarioDefinition.new( @@ -161,7 +156,6 @@ module En57 batch_size: @batch_size, setup: @setup, call_block: @call_block, - verify: @verify, ) end end @@ -199,10 +193,7 @@ module En57 define_method(:call) do |measure| instance_exec(measure, &definition.call_block) - verify end - - define_method(:verify) { instance_exec(&definition.verify) } end .tap { definitions << it } end @@ -233,9 +224,8 @@ module En57 def run(measure) warmup reset_retry_count - verified = true - @runs.times { verified = call(measure) } - verified + @runs.times { call(measure) } + nil end private @@ -290,10 +280,9 @@ module En57 PgEphemeral.with_server(instance_name:) do |server| samples = [] scenario = mk_scenario.call(server.url, 2) - verified = - scenario.run( - ->(&block) { samples << ::Benchmark.realtime { block.call } }, - ) + scenario.run( + ->(&block) { samples << ::Benchmark.realtime { block.call } }, + ) measurement = Measurement.from(samples) Result.new( @@ -305,12 +294,11 @@ module En57 max: measurement.max, median: measurement.median, retry_count: scenario.retry_count, - verified:, ) end end - @formatter.format(results.select(&:verified)) + @formatter.format(results) end end diff --git a/test/test_benchmark.rb b/test/test_benchmark.rb index 41e51e7..23d4cd5 100644 --- a/test/test_benchmark.rb +++ b/test/test_benchmark.rb @@ -10,7 +10,7 @@ module En57 cover "En57::Benchmark::CLI#run" cover "En57::Benchmark::Scenario#concurrently" - def test_table_formats_verified_results + def test_table_formats_results output = Table.new.format( [ @@ -23,7 +23,6 @@ module En57 max: 0.002, median: 0.0015, retry_count: 12, - verified: true, ), ], ) @@ -50,7 +49,6 @@ module En57 max: 0.001, median: 0.001, retry_count: 1, - verified: true, ), Result.new( name: "longer", @@ -61,7 +59,6 @@ module En57 max: 0.01, median: 0.01, retry_count: 100, - verified: true, ), ], ) @@ -76,28 +73,7 @@ module En57 ) end - def test_table_omits_unverified_results - assert_equal( - "", - Table.new.format( - [ - Result.new( - name: "scenario", - runs: 50, - mean: 0.00123, - stddev: 0.00045, - min: 0.001, - max: 0.002, - median: 0.0015, - retry_count: 12, - verified: false, - ), - ], - ), - ) - end - - def test_runner_formats_only_verified_results + def test_runner_formats_results formatter = Object.new formatted_results = nil @@ -107,16 +83,15 @@ module En57 end server = Data.define(:url).new("postgres://example") - mk_scenario = ->(name, verified) do + mk_scenario = ->(name) do ->(_database_url, _warmup_runs) do Data - .define(:name, :runs, :verified, :retry_count) do + .define(:name, :runs, :retry_count) do def run(measure) 3.times { measure.call { nil } } - verified end end - .new(name, 1, verified, 3) + .new(name, 1, 3) end end @@ -128,16 +103,16 @@ module En57 Runner.new( formatter:, scenarios: { - "verified" => mk_scenario.call("verified", true), - "unverified" => mk_scenario.call("unverified", false), + "first" => mk_scenario.call("first"), + "second" => mk_scenario.call("second"), }, ).run end assert_equal("formatted", output) - assert_equal(["verified"], formatted_results.map(&:name)) - assert_equal([1], formatted_results.map(&:runs)) - assert_equal([3], formatted_results.map(&:retry_count)) + assert_equal(%w[first second], formatted_results.map(&:name)) + assert_equal([1, 1], formatted_results.map(&:runs)) + assert_equal([3, 3], formatted_results.map(&:retry_count)) end def test_runner_uses_scenario_instance_names_and_database_urls @@ -266,7 +241,6 @@ module En57 measure.call { @call_measured = true } nil end - verify { @setup_called && @call_measured } end scenario = scenario_class.build( @@ -285,7 +259,8 @@ module En57 assert_equal(8, scenario.runs) assert_equal(2, scenario.instance_variable_get(:@concurrency)) assert_equal(3, scenario.instance_variable_get(:@batch_size)) - assert_equal(true, scenario.run(->(&block) { block.call })) + scenario.run(->(&block) { block.call }) + assert_equal(true, scenario.instance_variable_get(:@call_measured)) ensure Scenario.definitions.replace(original_definitions) @@ -314,26 +289,6 @@ module En57 Scenario.definitions.replace(original_definitions) end - def test_scenario_define_uses_verify_block - original_definitions = Scenario.definitions.dup - scenario_class = - Scenario.define do - database_instance "unverified" - name "Unverified scenario" - verify { false } - end - scenario = - scenario_class.build( - database_url: "postgres://example", - warmup_runs: 0, - runs: 1, - ) - - assert_equal(false, scenario.run(->(&block) { block.call })) - ensure - Scenario.definitions.replace(original_definitions) - end - def test_scenario_define_defaults original_definitions = Scenario.definitions.dup scenario_class = @@ -351,7 +306,7 @@ module En57 assert_equal(7, scenario.runs) assert_equal(1, scenario.instance_variable_get(:@concurrency)) assert_equal(100, scenario.instance_variable_get(:@batch_size)) - assert_equal(true, scenario.run(->(&block) { block.call })) + scenario.run(->(&block) { block.call }) ensure Scenario.definitions.replace(original_definitions) end @@ -410,10 +365,10 @@ module En57 ) assert_equal(0, scenario.retry_count) - assert_equal(true, scenario.run(->(&block) { block.call })) + scenario.run(->(&block) { block.call }) end - def test_scenario_verifies_when_no_measured_runs + def test_scenario_runs_when_no_measured_runs scenario = Scenario.new( name: "empty", @@ -424,7 +379,7 @@ module En57 batch_size: 1, ) - assert_equal(true, scenario.run(->(&block) { block.call })) + scenario.run(->(&block) { block.call }) end def test_scenario_counts_retries_after_warmup @@ -449,7 +404,8 @@ module En57 end .new - assert_equal(true, scenario.run(->(&block) { block.call })) + scenario.run(->(&block) { block.call }) + assert_equal(2, scenario.retry_count) end @@ -477,7 +433,8 @@ module En57 end .new(calls) - assert_equal(true, scenario.run(->(&block) { block.call })) + scenario.run(->(&block) { block.call }) + assert_equal(2, calls.value) end