Skip to content

Commit 68413db

Browse files
committed
Handle empty inputs correctly
1 parent b7c1314 commit 68413db

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

.github/workflows/benchmark.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ env:
6767
FORTIO_VERSION: "1.73.0"
6868
K6_VERSION: "1.3.0"
6969
VEGETA_VERSION: "12.13.0"
70-
# Benchmark parameters
70+
# Benchmark parameters (defaults in bench.rb unless overridden here for CI)
7171
ROUTES: ${{ github.event.inputs.routes }}
7272
RATE: ${{ github.event.inputs.rate || 'max' }}
73-
DURATION: ${{ github.event.inputs.duration || '30s' }}
74-
REQUEST_TIMEOUT: ${{ github.event.inputs.request_timeout || '60s' }}
75-
CONNECTIONS: ${{ github.event.inputs.connections || 10 }}
76-
MAX_CONNECTIONS: ${{ github.event.inputs.connections || 10 }}
73+
DURATION: ${{ github.event.inputs.duration }}
74+
REQUEST_TIMEOUT: ${{ github.event.inputs.request_timeout }}
75+
CONNECTIONS: ${{ github.event.inputs.connections }}
76+
MAX_CONNECTIONS: ${{ github.event.inputs.connections }}
7777
WEB_CONCURRENCY: ${{ github.event.inputs.web_concurrency || 4 }}
7878
RAILS_MAX_THREADS: ${{ github.event.inputs.rails_threads || 3 }}
7979
RAILS_MIN_THREADS: ${{ github.event.inputs.rails_threads || 3 }}
80-
TOOLS: ${{ github.event.inputs.tools || 'fortio,vegeta,k6' }}
80+
TOOLS: ${{ github.event.inputs.tools }}
8181

8282
jobs:
8383
benchmark:

spec/performance/bench.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
# Benchmark parameters
1111
PRO = ENV.fetch("PRO", "false") == "true"
1212
APP_DIR = PRO ? "react_on_rails_pro/spec/dummy" : "spec/dummy"
13-
ROUTES = ENV.fetch("ROUTES", nil)
14-
BASE_URL = ENV.fetch("BASE_URL", "localhost:3001")
13+
ROUTES = ENV["ROUTES"].to_s.empty? ? nil : ENV.fetch("ROUTES", nil)
14+
BASE_URL = ENV["BASE_URL"] || "localhost:3001"
1515
# requests per second; if "max" will get maximum number of queries instead of a fixed rate
16-
RATE = ENV.fetch("RATE", "50")
16+
RATE = ENV["RATE"] || "50"
1717
# concurrent connections/virtual users
18-
CONNECTIONS = ENV.fetch("CONNECTIONS", "10").to_i
18+
CONNECTIONS = (ENV["CONNECTIONS"] || 10).to_i
1919
# maximum connections/virtual users
20-
MAX_CONNECTIONS = ENV.fetch("MAX_CONNECTIONS", CONNECTIONS).to_i
20+
MAX_CONNECTIONS = (ENV["MAX_CONNECTIONS"] || CONNECTIONS).to_i
2121
# benchmark duration (duration string like "30s", "1m", "90s")
22-
DURATION = ENV.fetch("DURATION", "30s")
22+
DURATION = ENV["DURATION"] || "30s"
2323
# request timeout (duration string as above)
24-
REQUEST_TIMEOUT = ENV.fetch("REQUEST_TIMEOUT", "60s")
24+
REQUEST_TIMEOUT = ENV["REQUEST_TIMEOUT"] || "60s"
2525
# Tools to run (comma-separated)
26-
TOOLS = ENV.fetch("TOOLS", "fortio,vegeta,k6").split(",")
26+
TOOLS = (ENV["TOOLS"] || "fortio,vegeta,k6").split(",")
2727

2828
OUTDIR = "bench_results"
2929
SUMMARY_TXT = "#{OUTDIR}/summary.txt".freeze
@@ -93,11 +93,13 @@ def get_benchmark_routes(app_dir)
9393
# Get all routes to benchmark
9494
routes =
9595
if ROUTES
96-
ROUTES.split(",").map(&:strip)
96+
ROUTES.split(",").map(&:strip).reject(&:empty?)
9797
else
9898
get_benchmark_routes(APP_DIR)
9999
end
100100

101+
raise "No routes to benchmark" if routes.empty?
102+
101103
validate_rate(RATE)
102104
validate_positive_integer(CONNECTIONS, "CONNECTIONS")
103105
validate_positive_integer(MAX_CONNECTIONS, "MAX_CONNECTIONS")

0 commit comments

Comments
 (0)