From 5dca55a50e12373cceac154d0091fa1bb99d42e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pacana?= Date: Wed, 20 May 2026 13:31:09 +0200 Subject: [PATCH] Override number of benchmark runs easily --- bin/benchmark | 4 +++- lib/en57/benchmark.rb | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/benchmark b/bin/benchmark index 3bf2dba..b1265ca 100755 --- a/bin/benchmark +++ b/bin/benchmark @@ -2,4 +2,6 @@ require_relative "../lib/en57/benchmark" -puts En57::Benchmark::Runner.classic.run +puts En57::Benchmark::Runner.classic( + runs: Integer(ENV.fetch("BENCHMARK_RUNS", 10)), + ).run diff --git a/lib/en57/benchmark.rb b/lib/en57/benchmark.rb index ea0d5ca..65fb10b 100644 --- a/lib/en57/benchmark.rb +++ b/lib/en57/benchmark.rb @@ -117,7 +117,7 @@ module En57 end class Runner - def self.classic + def self.classic(runs: 50) new( formatter: Table.new, scenarios: { @@ -129,7 +129,7 @@ module En57 name: "Concurrent append, non-conflicting tags", database_url:, measure:, - runs: ENV.fetch("BENCHMARK_RUNS", 1), + runs:, concurrency: 10, batch_size: 100, ) @@ -139,7 +139,7 @@ module En57 name: "Concurrent append, no fail_if", database_url:, measure:, - runs: ENV.fetch("BENCHMARK_RUNS", 1), + runs:, concurrency: 10, batch_size: 100, ) @@ -149,7 +149,7 @@ module En57 name: "Concurrent append, conflicting tags", database_url:, measure:, - runs: ENV.fetch("BENCHMARK_RUNS", 1), + runs:, concurrency: 10, batch_size: 100, ) @@ -284,7 +284,9 @@ module En57 begin @event_store.append(events, fail_if: scope.after(position)) rescue AppendConditionViolated - scope.each_with_position { |_event, event_position| position = event_position } + scope.each_with_position do |_event, event_position| + position = event_position + end retry end end -- 2.51.2