CALL_TYPES.each { |k, v| puts "#{k}.label #{v}" }
else
- counts = uri_and_times_from_status(server).
- collect { |x, y| [categorise_uri(x), y] }.
- inject(Hash.new) do |h, e|
+ counts = uri_and_times_from_status(server)
+ .collect { |x, y| [categorise_uri(x), y] }
+ .each_with_object(Hash.new) do |h, e|
category, time = e
- if h.has_key? category
+ if h.key? category
h[category] += [time]
else
h[category] = [time]
end
- h
end
CALL_TYPES.keys.each do |type|
count = counts[type] || [0]
- avg = count.inject(0) { |x, y|x + y } / (1.0 * count.length)
+ avg = count.inject(0) { |a, e| a + e } / (1.0 * count.length)
puts "#{type}.value #{avg}"
end
end