Skip to content

Instantly share code, notes, and snippets.

@a-b
Created August 31, 2012 01:42
Show Gist options
  • Save a-b/3547551 to your computer and use it in GitHub Desktop.
Save a-b/3547551 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
FNAME = 'ff'
@lag_data = {}
File.open(FNAME).each do |line|
line.gsub!("\n",'')
time_area = line.split[2]
t1,t2,t3,t4,t5 = time_area.split("/").map(&:to_i)
@server_lag = t5 - t1
@lag_data[@server_lag] = @lag_data[@server_lag].to_i + 1
end
@lag_data.sort.reverse.each do |key, val|
@key=key
@lag_data[key] = @lag_data.select{|k| k < @key}.values.inject(:+).to_i + val
end
@lag_data.sort.each {|k,v| puts [k,v] * "\t"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment