Created
October 1, 2012 09:23
-
-
Save commuterjoy/3810521 to your computer and use it in GitHub Desktop.
tsung-fullstats parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A script to extract data from tsung-fullstats.log files | |
def parse(log, key) | |
File.read(log).split('{').map { |entry| | |
next unless (entry =~ /#{key}/) | |
entry.scan(/\[.+\]/m).map { |group| | |
group.split(',').map { |timestamp| | |
timestamp.scan(/[\d\.]/).join('') | |
} | |
} | |
}.compact!.flatten! | |
end | |
def usage | |
puts " | |
Usage: #{__FILE__} <path/to/tsung-fullstats.log> <stat> | |
<stat> | |
request: Response time for each request. | |
connect: Duration of the connection establishment. | |
page: Response time for each set of requests. | |
" | |
exit 1 | |
end | |
def app | |
opts = { :log => ARGV.first, :key => ARGV[1]} | |
usage unless (opts[:log] && opts[:key] && (opts[:key] =~ /^(page|connect|request)$/)) | |
key = "(sample,%s)" % [opts[:key]] | |
parse(opts[:log], opts[:key]).join("\n") | |
end | |
puts app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fails for "transactions" because the sample value is not a list
WORKS:
{sample,connect,
[0.593017578125,0.47900390625,0.509033203125,0.512939453125,
0.427978515625,0.509033203125,0.573974609375,0.62890625,0.505859375,
60.676025390625]}
FAILS:
{sample,tr_foo,2.0390625}
FIX BELOW: