Skip to content

Commit 9a0a65d

Browse files
committed
Allow specifying routes
1 parent 8727cdb commit 9a0a65d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.github/workflows/benchmark.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
required: false
1010
default: false
1111
type: boolean
12+
routes:
13+
description: 'Comma-separated routes to benchmark (e.g., "/,/hello"). Leave empty to auto-detect from Rails.'
14+
required: false
15+
type: string
1216
rate:
1317
description: 'Requests per second (use "max" for maximum throughput)'
1418
required: false
@@ -62,6 +66,7 @@ env:
6266
K6_VERSION: "1.3.0"
6367
VEGETA_VERSION: "12.13.0"
6468
# Benchmark parameters
69+
ROUTES: ${{ github.event.inputs.routes }}
6570
RATE: ${{ github.event.inputs.rate || 'max' }}
6671
DURATION: ${{ github.event.inputs.duration || '30s' }}
6772
REQUEST_TIMEOUT: ${{ github.event.inputs.request_timeout || '60s' }}

spec/performance/bench.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
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)
1314
BASE_URL = ENV.fetch("BASE_URL", "localhost:3001")
1415
# requests per second; if "max" will get maximum number of queries instead of a fixed rate
1516
RATE = ENV.fetch("RATE", "50")
@@ -90,7 +91,12 @@ def get_benchmark_routes(app_dir)
9091
end
9192

9293
# Get all routes to benchmark
93-
routes = get_benchmark_routes(APP_DIR)
94+
routes =
95+
if ROUTES
96+
ROUTES.split(",").map(&:strip)
97+
else
98+
get_benchmark_routes(APP_DIR)
99+
end
94100

95101
validate_rate(RATE)
96102
validate_positive_integer(CONNECTIONS, "CONNECTIONS")
@@ -109,6 +115,7 @@ def get_benchmark_routes(app_dir)
109115
puts <<~PARAMS
110116
Benchmark parameters:
111117
- APP_DIR: #{APP_DIR}
118+
- ROUTES: #{ROUTES || 'auto-detect from Rails'}
112119
- BASE_URL: #{BASE_URL}
113120
- RATE: #{RATE}
114121
- DURATION: #{DURATION}

0 commit comments

Comments
 (0)