bench/runner.rb in sanford-0.4.0 vs bench/runner.rb in sanford-0.6.0
- old
+ new
@@ -5,14 +5,14 @@
module Bench
class Runner
# this should match up with bench/services host and port
- HOST_AND_PORT = [ '127.0.0.1', 12000 ]
+ HOST_AND_PORT = [ '127.0.0.1', 59284 ]
REQUESTS = [
- [ 'v1', 'simple', {}, 10000 ]
+ [ 'v1', 'simple', {}, 10000 ]
]
TIME_MODIFIER = 10 ** 4 # 4 decimal places
def initialize(options = {})
@@ -34,11 +34,11 @@
def benchmark_service(version, name, params, times, show_result = false)
benchmarks = []
output "\nHitting #{name.inspect} service with #{params.inspect}, #{times} times"
[*(1..times.to_i)].each do |index|
- benchmark = self.hit_service(name, version, params.merge({ :request_number => index }), show_result)
+ benchmark = self.hit_service(version, name, params.merge({ :request_number => index }), show_result)
benchmarks << self.round_time(benchmark.real * 1000.to_f)
output('.', false) if ((index - 1) % 100 == 0) && !show_result
end
output("\n", false)
@@ -70,17 +70,16 @@
end
output "\n"
end
- protected
def hit_service(version, name, params, show_result)
Benchmark.measure do
begin
client = Bench::Client.new(*HOST_AND_PORT)
- response = client.call(name, version, params)
+ response = client.call(version, name, params)
if show_result
output "Got a response:"
output " #{response.status}"
output " #{response.data.inspect}"
end
@@ -88,9 +87,11 @@
puts "FAILED -> #{exception.class}: #{exception.message}"
puts exception.backtrace.join("\n")
end
end
end
+
+ protected
def output(message, puts = true)
method = puts ? :puts : :print
self.send(method, message)
@file.send(method, message)