Skip to content

Commit fd5df03

Browse files
waghanzatbrand
authored andcommitted
specify client host / port to bench (#163)
1 parent 807f37d commit fd5df03

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/src/client.cr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class Client
55
def initialize
66
@threads = 16
77
@requests = 1000
8+
@host = "localhost"
9+
@port = 3000
810

911
OptionParser.parse! do |parser|
1012
parser.banner = "Usage: time ./bin/benchmark [options]"
@@ -14,12 +16,18 @@ class Client
1416
parser.on("-r REQUESTS", "--requests=REQUESTS", "# of iterations of requests") do |requests|
1517
@requests = requests.to_i
1618
end
19+
parser.on("-h HOST", "--host=HOST", "IP / address of host to test") do |host|
20+
@host = host
21+
end
22+
parser.on("-p PORT", "--port=PORT", "Port to test") do |port|
23+
@port = port.to_i
24+
end
1725
end
1826
end
1927

2028
macro run_spawn
2129
spawn do
22-
c = HTTP::Client.new "localhost", 3000
30+
c = HTTP::Client.new @host, @port
2331
@requests.times do |t|
2432
r = c.get "/"
2533
abort "status code should be 200 when GET /" if r.status_code != 200

0 commit comments

Comments
 (0)