premiere-libtorrent/parse_session_stats.py

71 lines
3.9 KiB
Python
Raw Normal View History

2010-03-05 19:12:23 +01:00
#! /usr/bin/env python
# Copyright Arvid Norberg 2008. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import os, sys, time
2008-12-27 03:22:20 +01:00
stat = open(sys.argv[1])
line = stat.readline()
while not 'second:' in line:
line = stat.readline()
keys = line.strip().split(':')[1:]
axes = ['x1y2', 'x1y2', 'x1y1', 'x1y1', 'x1y1', 'x1y1', 'x1y1', 'x1y1', 'x1y2']
2008-12-27 03:22:20 +01:00
def gen_report(name, lines):
out = open('session_stats_%s.gnuplot' % name, 'wb')
print >>out, "set term png size 1200,700"
print >>out, 'set output "session_stats_%s.png"' % name
print >>out, 'set xrange [0:*]'
print >>out, 'set xlabel "time (s)"'
print >>out, 'set ylabel "number"'
print >>out, 'set y2label "Rate (B/s)"'
print >>out, 'set y2range [0:*]'
print >>out, 'set y2tics auto'
print >>out, "set tics nomirror"
2008-12-27 03:22:20 +01:00
print >>out, "set style data lines"
print >>out, "set key box"
print >>out, 'plot',
column = 2
2011-02-02 04:37:09 +01:00
first = True
for k in lines:
try:
column = keys.index(k) + 2
except:
print '"%s" not found' % k
continue;
2011-02-02 04:37:09 +01:00
if not first: print >>out, ', ',
axis = 'x1y1'
if column-2 < len(axes): axis = axes[column-2]
print >>out, ' "%s" using 1:%d title "%s" axes %s with steps' % (sys.argv[1], column, k, axis),
2011-02-02 04:37:09 +01:00
first = False
2008-12-27 03:22:20 +01:00
column = column + 1
2011-02-02 04:37:09 +01:00
print >>out, ''
2008-12-27 03:22:20 +01:00
out.close()
os.system('gnuplot session_stats_%s.gnuplot' % name);
gen_report('torrents', ['downloading torrents', 'seeding torrents', 'checking torrents', 'stopped torrents', 'upload-only torrents', 'error torrents'])
gen_report('peers', ['peers', 'connecting peers', 'connection attempts', 'banned peers', 'max connections'])
2011-02-04 05:31:20 +01:00
gen_report('peers_list', ['num list peers', 'peer storage bytes'])
gen_report('overall_rates', ['upload rate', 'download rate', 'smooth upload rate', 'smooth download rate'])
2011-02-04 07:31:47 +01:00
gen_report('peer_dl_rates', ['peers down 0', 'peers down 0-2', 'peers down 2-5', 'peers down 5-10', 'peers down 50-100', 'peers down 100-'])
gen_report('peer_dl_rates2', ['peers down 0-2', 'peers down 2-5', 'peers down 5-10', 'peers down 50-100', 'peers down 100-'])
2011-02-04 07:31:47 +01:00
gen_report('peer_ul_rates', ['peers up 0', 'peers up 0-2', 'peers up 2-5', 'peers up 5-10', 'peers up 50-100', 'peers up 100-'])
gen_report('peer_ul_rates2', ['peers up 0-2', 'peers up 2-5', 'peers up 5-10', 'peers up 50-100', 'peers up 100-'])
2011-03-18 06:49:31 +01:00
gen_report('disk', ['disk write queued bytes', 'disk queue limit', 'disk queue low watermark'])
gen_report('peers_upload', ['peers up interested', 'peers up unchoked', 'peers up requests', 'peers disk-up', 'peers bw-up'])
gen_report('peers_download', ['peers down interesting', 'peers down unchoked', 'peers down requests', 'peers disk-down', 'peers bw-down'])
gen_report('peer_errors', ['error peers', 'peer disconnects', 'peers eof', 'peers connection reset', 'connect timeouts', 'uninteresting peers disconnect', 'banned for hash failure'])
gen_report('piece_picker_end_game', ['end game piece picker blocks', 'piece picker blocks', 'piece picks', 'reject piece picks', 'unchoke piece picks', 'incoming redundant piece picks', 'incoming piece picks', 'end game piece picks', 'snubbed piece picks'])
gen_report('piece_picker', ['piece picks', 'reject piece picks', 'unchoke piece picks', 'incoming redundant piece picks', 'incoming piece picks', 'end game piece picks', 'snubbed piece picks'])
gen_report('bandwidth', ['% failed payload bytes', '% wasted payload bytes', '% protocol bytes'])
2011-03-18 04:50:38 +01:00
gen_report('disk_time', ['disk read time', 'disk write time', 'disk queue time', 'disk hash time', 'disk job time', 'disk sort time'])
2011-03-14 04:35:18 +01:00
gen_report('disk_cache_hits', ['disk block read', 'read cache hits', 'disk block written'])
gen_report('disk_cache', ['read disk cache size', 'disk cache size', 'disk buffer allocations', 'cache size'])
2011-03-11 08:37:12 +01:00
gen_report('disk_queue', ['disk queue size', 'disk queued bytes'])
2011-03-13 05:34:57 +01:00
gen_report('waste', ['failed bytes', 'redundant bytes', 'download rate'])
gen_report('connect_candidates', ['connect candidates'])