Skip to content

Instantly share code, notes, and snippets.

@justinstoller
Created December 13, 2017 18:37
Show Gist options
  • Save justinstoller/94e162496518a6587b7308e90712955b to your computer and use it in GitHub Desktop.
Save justinstoller/94e162496518a6587b7308e90712955b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'csv'
inputfile = ARGV[0]
intermediate = {
'node' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta plugins' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta pluginfacts' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'catalog' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'report' => {'KOs' => 0, 'values' => [], 'ok' => 0}
}
CSV.foreach(inputfile, col_sep: "\t") do |row|
if row[0] == 'REQUEST'
type = row[4]
if row[7] != 'OK'
intermediate[type]['KOs'] += 1
else
intermediate[type]['values'] << row[6].to_i - row[5].to_i
intermediate[type]['ok'] += 1
end
end
end
output = []
intermediate.each_pair do |type, info|
info['values'].sort!
length = info['ok']
median = (length * 0.5).to_i
p90 = (length * 0.9).to_i
p95 = (length * 0.95).to_i
p99 = (length * 0.99).to_i
output << [
type,
info['values'].first,
info['values'][median],
info['values'][p90],
info['values'][p95],
info['values'][p99],
info['values'].last,
info['ok'] + info['KOs'],
info['KOs']
]
end
puts 'endpoint,min,median,p90,p95,p99,max,count,kos'
output.each do |row|
puts row.join(',')
end
sellout:gatling justin$ time ./calc.rb logs/jruby-9.1.11.0-with-jit-and-mrpi-simulation.log > csvs/jruby-9.1.11.0-with-jit-and-mrpi-simulation.csv
real 0m6.926s
user 0m6.871s
sys 0m0.041s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment