call_times = []
client_times = []
connection_failures = []
+ connection_errors = []
shortest_call = 0
shortest_client = 0
longest_call = 0
cur_client = nil
when :connection_failure
connection_failures << time
+ when :connection_error
+ connection_errors << time
end
end
end
@report[:total_clients] = client_times.inject(0.0) { |a,t| a += t }
@report[:avg_clients] = @report[:total_clients] / client_times.size
@report[:connection_failures] = connection_failures.size
+ @report[:connection_errors] = connection_errors.size
@report[:shortest_call] = shortest_call
@report[:shortest_client] = shortest_client
@report[:longest_call] = longest_call
puts
failures = (@report[:connection_failures] > 0)
tabulate fmt,
- [["Connection failures", "%d", *(failures ? [[:red, :bold]] : [])], @report[:connection_failures]],
+ [["Connection failures", "%d", [:red, :bold]], @report[:connection_failures]],
+ [["Connection errors", "%d", [:red, :bold]], @report[:connection_errors]],
["Average time per call", @report[:avg_calls]],
["Average time per client (%d calls)" % @calls_per_client, @report[:avg_clients]],
["Total time for all calls", @report[:total_calls]],
f = fmt
l, f, c = l if Array === l
fmtstr = "%-#{label_width+1}s #{f}"
- if STDOUT.tty? and c
+ if STDOUT.tty? and c and v.to_i > 0
fmtstr = "\e[#{[*c].map { |x| ANSI[x] } * ";"}m" + fmtstr + "\e[#{ANSI[:reset]}m"
end
puts fmtstr % [l+":", v]
protocol = Thrift::BinaryProtocol.new(transport)
client = ThriftBenchmark::BenchmarkService::Client.new(protocol)
begin
+ start = Time.now
transport.open
+ Marshal.dump [:start, start], STDOUT
rescue
Marshal.dump [:connection_failure, Time.now], STDOUT
else
- Marshal.dump [:start, Time.now], STDOUT
- @calls_per_client.times do
- Marshal.dump [:call_start, Time.now], STDOUT
- client.fibonacci(15)
- Marshal.dump [:call_end, Time.now], STDOUT
+ begin
+ @calls_per_client.times do
+ Marshal.dump [:call_start, Time.now], STDOUT
+ client.fibonacci(15)
+ Marshal.dump [:call_end, Time.now], STDOUT
+ end
+ transport.close
+ Marshal.dump [:end, Time.now], STDOUT
+ rescue Thrift::TransportException
+ Marshal.dump [:connection_error, Time.now], STDOUT
end
- transport.close
- Marshal.dump [:end, Time.now], STDOUT
end
end
end