Skip to content

Commit 24e38a5

Browse files
committed
Replace DURATION_SEC with DURATION
1 parent f24e79f commit 24e38a5

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

.github/workflows/benchmark.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ on:
1414
required: false
1515
default: 'max'
1616
type: string
17-
duration_sec:
18-
description: 'Duration in seconds'
17+
duration:
18+
description: 'Duration (e.g., "30s", "1m", "90s")'
1919
required: false
20-
default: 30
21-
type: number
20+
default: '30s'
21+
type: string
2222
request_timeout:
2323
description: 'Request timeout (e.g., "60s", "1m", "90s")'
2424
required: false
@@ -63,7 +63,7 @@ env:
6363
VEGETA_VERSION: "12.13.0"
6464
# Benchmark parameters
6565
RATE: ${{ github.event.inputs.rate || 'max' }}
66-
DURATION_SEC: ${{ github.event.inputs.duration_sec || 30 }}
66+
DURATION: ${{ github.event.inputs.duration || '30s' }}
6767
REQUEST_TIMEOUT: ${{ github.event.inputs.request_timeout || '60s' }}
6868
CONNECTIONS: ${{ github.event.inputs.connections || 10 }}
6969
MAX_CONNECTIONS: ${{ github.event.inputs.max_connections || github.event.inputs.connections || 10 }}

spec/performance/bench.rb

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
# concurrent connections/virtual users
1616
CONNECTIONS = ENV.fetch("CONNECTIONS", "10").to_i
1717
# maximum connections/virtual users
18-
MAX_CONNECTIONS = ENV.fetch("MAX_CONNECTIONS", CONNECTIONS.to_s).to_i
19-
DURATION_SEC = ENV.fetch("DURATION_SEC", "10").to_f
20-
DURATION = "#{DURATION_SEC}s".freeze
21-
# request timeout (duration string like "60s", "1m", "90s")
18+
MAX_CONNECTIONS = ENV.fetch("MAX_CONNECTIONS", CONNECTIONS).to_i
19+
# benchmark duration (duration string like "30s", "1m", "90s")
20+
DURATION = ENV.fetch("DURATION", "30s")
21+
# request timeout (duration string as above)
2222
REQUEST_TIMEOUT = ENV.fetch("REQUEST_TIMEOUT", "60s")
2323
# Tools to run (comma-separated)
2424
TOOLS = ENV.fetch("TOOLS", "fortio,vegeta,k6").split(",")
@@ -50,15 +50,9 @@ def validate_positive_integer(value, name)
5050
end
5151

5252
def validate_duration(value, name)
53-
return if value.is_a?(Numeric) && value.positive?
54-
55-
raise "#{name} must be a positive number (got: '#{value}')"
56-
end
57-
58-
def validate_timeout(value)
5953
return if value.match?(/^(\d+(\.\d+)?[smh])+$/)
6054

61-
raise "REQUEST_TIMEOUT must be a duration like '60s', '1m', '1.5m' (got: '#{value}')"
55+
raise "#{name} must be a duration like '10s', '1m', '1.5m' (got: '#{value}')"
6256
end
6357

6458
def parse_json_file(file_path, tool_name)
@@ -74,8 +68,8 @@ def parse_json_file(file_path, tool_name)
7468
validate_rate(RATE)
7569
validate_positive_integer(CONNECTIONS, "CONNECTIONS")
7670
validate_positive_integer(MAX_CONNECTIONS, "MAX_CONNECTIONS")
77-
validate_duration(DURATION_SEC, "DURATION_SEC")
78-
validate_timeout(REQUEST_TIMEOUT)
71+
validate_duration(DURATION, "DURATION")
72+
validate_duration(REQUEST_TIMEOUT, "REQUEST_TIMEOUT")
7973

8074
raise "MAX_CONNECTIONS (#{MAX_CONNECTIONS}) must be >= CONNECTIONS (#{CONNECTIONS})" if MAX_CONNECTIONS < CONNECTIONS
8175

@@ -93,7 +87,7 @@ def parse_json_file(file_path, tool_name)
9387
puts <<~PARAMS
9488
Benchmark parameters:
9589
- RATE: #{RATE}
96-
- DURATION_SEC: #{DURATION_SEC}
90+
- DURATION: #{DURATION}
9791
- REQUEST_TIMEOUT: #{REQUEST_TIMEOUT}
9892
- CONNECTIONS: #{CONNECTIONS}
9993
- MAX_CONNECTIONS: #{MAX_CONNECTIONS}

0 commit comments

Comments
 (0)