def initialize(redis) @redis = redis end def record(path) redis.incr("stats:#{path}") end def fetch(path) redis.get("stats:#{path}") end protected attr_reader :redis end
%w{name time mean_rate 95th_percentile} out = CSV.generate do |csv| csv << columns.to_a ARGF.each_line do |l| fields = l.split next if fields[0] != 'I,' metrics = fields.slice(7..-1).inject({}) do |hsh, str| name, value = str.split('=') hsh.update(name => value) end csv << columns.inject([]) { |row, name| row << metrics[name] } end end puts out