forked from premiere/premiere-libtorrent
remove some unused python scripts. add vim modelines to python files
This commit is contained in:
parent
ca7313580e
commit
9eb5595c48
|
@ -35,7 +35,6 @@ project tools
|
|||
<link>static
|
||||
;
|
||||
|
||||
exe parse_access_log : parse_access_log.cpp ;
|
||||
exe dht : dht_put.cpp : <include>../ed25519/src ;
|
||||
exe session_log_alerts : session_log_alerts.cpp ;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
tool_programs = \
|
||||
dht_put \
|
||||
session_log_alerts
|
||||
|
||||
if ENABLE_EXAMPLES
|
||||
|
@ -7,19 +8,16 @@ endif
|
|||
|
||||
EXTRA_PROGRAMS = $(tool_programs)
|
||||
EXTRA_DIST = Jamfile \
|
||||
parse_bandwidth_log.py \
|
||||
parse_buffer_log.py \
|
||||
parse_dht_log.py \
|
||||
parse_dht_rtt.py \
|
||||
parse_dht_stats.py \
|
||||
parse_disk_buffer_log.py\
|
||||
parse_memory_log.py \
|
||||
parse_peer_log.py \
|
||||
parse_sample.py \
|
||||
parse_session_stats.py \
|
||||
parse_utp_log.py
|
||||
|
||||
session_log_alerts_SOURCES = session_log_alerts.cpp
|
||||
dht_put_SOURCES = dht_put.cpp
|
||||
|
||||
LDADD = $(top_builddir)/src/libtorrent-rasterbar.la
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import socket
|
||||
import sys
|
||||
|
|
|
@ -206,7 +206,14 @@ void load_dht_state(lt::session& s)
|
|||
{
|
||||
std::vector<char> state;
|
||||
state.resize(size);
|
||||
fread(&state[0], 1, state.size(), f);
|
||||
std::size_t ret = fread(&state[0], 1, state.size(), f);
|
||||
if (ret != state.size())
|
||||
{
|
||||
std::fprintf(stderr, "failed to read .dht: (%d) %s"
|
||||
, errno, strerror(errno));
|
||||
std::fclose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import os
|
||||
|
||||
|
|
|
@ -1,180 +0,0 @@
|
|||
/*
|
||||
|
||||
Copyright (c) 2011, Arvid Norberg
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/io.hpp"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cerrno>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <cstdio>
|
||||
#include <cinttypes> // for PRId64 et.al.
|
||||
|
||||
using namespace lt;
|
||||
using namespace lt::detail; // for write_* and read_*
|
||||
|
||||
void print_usage()
|
||||
{
|
||||
std::fprintf(stderr, "usage: parse_access_log log-file\n\n"
|
||||
"prints a gnuplot readable data file to stdout\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct file_op
|
||||
{
|
||||
std::uint64_t timestamp;
|
||||
std::uint64_t offset;
|
||||
std::uint8_t event;
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc != 2) print_usage();
|
||||
|
||||
FILE* log_file = std::fopen(argv[1], "r");
|
||||
if (log_file == nullptr)
|
||||
{
|
||||
std::fprintf(stderr, "failed to open logfile: %s\n%d: %s\n"
|
||||
, argv[1], errno, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* writes_file = std::fopen("writes.log", "w+");
|
||||
FILE* reads_file = std::fopen("reads.log", "w+");
|
||||
|
||||
FILE* writes_elev_file = std::fopen("writes_elevator.log", "w+");
|
||||
FILE* reads_elev_file = std::fopen("reads_elevator.log", "w+");
|
||||
|
||||
|
||||
using op_map = std::map<std::uint32_t, file_op>;
|
||||
op_map outstanding_ops;
|
||||
|
||||
std::uint64_t first_timestamp = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char entry[21];
|
||||
char* ptr = entry;
|
||||
int ret = int(fread(&entry, 1, sizeof(entry), log_file));
|
||||
if (ret != sizeof(entry)) break;
|
||||
|
||||
file_op op;
|
||||
op.timestamp = read_uint64(ptr);
|
||||
op.offset = read_uint64(ptr);
|
||||
std::uint32_t event_id = read_uint32(ptr);
|
||||
op.event = read_uint8(ptr);
|
||||
|
||||
if (first_timestamp == 0) first_timestamp = op.timestamp;
|
||||
|
||||
bool write = (op.event & 1) != 0;
|
||||
bool complete = (op.event & 2) != 0;
|
||||
if (complete)
|
||||
{
|
||||
FILE* out_file = nullptr;
|
||||
op_map::iterator i = outstanding_ops.find(event_id);
|
||||
if (i != outstanding_ops.end())
|
||||
{
|
||||
if (i->second.timestamp > op.timestamp)
|
||||
{
|
||||
std::fprintf(stderr, "end-event stamped before "
|
||||
"start-event: %" PRId64 " started at: %f\n"
|
||||
, op.offset, double(i->second.timestamp) / 1000000.f);
|
||||
i->second.timestamp = op.timestamp;
|
||||
}
|
||||
|
||||
out_file = write ? writes_file : reads_file;
|
||||
double start_time = double(i->second.timestamp - first_timestamp) / 1000000.0;
|
||||
double end_time = double(op.timestamp - first_timestamp) / 1000000.0;
|
||||
double duration_time = double(op.timestamp - i->second.timestamp) / 1000000.0;
|
||||
std::fprintf(out_file, "%f\t%" PRId64 "\t%f\n"
|
||||
, start_time, op.offset, duration_time);
|
||||
|
||||
out_file = write ? writes_elev_file : reads_elev_file;
|
||||
std::fprintf(out_file, "%f\t%" PRId64 "\n", end_time, op.offset);
|
||||
|
||||
outstanding_ops.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::fprintf(stderr, "no start event for (%u): %" PRId64 " ended at: %f\n"
|
||||
, event_id, op.offset, double(op.timestamp) / 1000000.f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
op_map::iterator i = outstanding_ops.find(event_id);
|
||||
if (i != outstanding_ops.end())
|
||||
{
|
||||
std::fprintf(stderr, "duplicate start event for (%u): %" PRId64 " at: %f"
|
||||
"(current start is at: %f)\n"
|
||||
, event_id, op.offset, double(i->second.timestamp - first_timestamp) / 1000000.f
|
||||
, double(op.timestamp - first_timestamp) / 1000000.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
outstanding_ops[event_id] = op;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::fclose(writes_file);
|
||||
std::fclose(reads_file);
|
||||
std::fclose(writes_elev_file);
|
||||
std::fclose(reads_elev_file);
|
||||
std::fclose(log_file);
|
||||
|
||||
FILE* gnuplot = std::fopen("file_access.gnuplot", "w+");
|
||||
|
||||
char const* gnuplot_file =
|
||||
"set term png size 1400,1024\n"
|
||||
"set output \"file_access.png\"\n"
|
||||
"set xlabel \"time (s)\"\n"
|
||||
"set ylabel \"file offset\"\n"
|
||||
"set style line 1 lc rgb \"#ff8888\"\n"
|
||||
"set style line 2 lc rgb \"#88ff88\"\n"
|
||||
"set style arrow 1 nohead ls 1\n"
|
||||
"set style arrow 2 nohead ls 2\n"
|
||||
"plot \"writes.log\" using 1:2:3:(0) title \"writes\" with vectors arrowstyle 1, "
|
||||
"\"reads.log\" using 1:2:3:(0) title \"reads\" with vectors arrowstyle 2\n";
|
||||
|
||||
std::fwrite(gnuplot_file, strlen(gnuplot_file), 1, gnuplot);
|
||||
std::fclose(gnuplot);
|
||||
|
||||
system("gnuplot file_access.gnuplot");
|
||||
|
||||
assert(outstanding_ops.empty());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
keys = [['upload rate', 'x1y1', 6], ['history entries', 'x1y2', 10], ['queue', 'x1y2', 4]]
|
||||
|
||||
out = open('bandwidth.gnuplot', 'wb')
|
||||
print("set term png size 1200,700", file=out)
|
||||
print('set output "bandwidth_manager.png"', file=out)
|
||||
print('set xrange [0:*]', file=out)
|
||||
print('set xlabel "time (ms)"', file=out)
|
||||
print('set ylabel "Rate (B/s)"', file=out)
|
||||
print('set ytics 10000', file=out)
|
||||
print('set y2label "number"', file=out)
|
||||
print('set y2range [0:*]', file=out)
|
||||
# print("set style data lines", file=out)
|
||||
print("set key box", file=out)
|
||||
print('plot', end=' ', file=out)
|
||||
for k, a, c in keys:
|
||||
print(' "%s" using 1:%d title "%s" axes %s with steps,' % (sys.argv[1], c, k, a), end=' ', file=out)
|
||||
print('x=0', file=out)
|
||||
out.close()
|
||||
|
||||
os.system('gnuplot bandwidth.gnuplot')
|
|
@ -1,98 +0,0 @@
|
|||
#!/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)
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
lines = open(sys.argv[1], 'rb').readlines()
|
||||
|
||||
# keys = ['send_buffer_utilization']
|
||||
keys = ['send_buffer_size', 'used_send_buffer', 'protocol_buffer']
|
||||
# keys = ['send_buffer_alloc', 'send_buffer', 'allocate_buffer_alloc', 'allocate_buffer', 'protocol_buffer']
|
||||
# keys = ['send_buffer_alloc', 'send_buffer', 'allocate_buffer_alloc', 'allocate_buffer', 'protocol_buffer',
|
||||
# 'append_send_buffer']
|
||||
|
||||
average = ['send_buffer_utilization', 'send_buffer_size', 'used_send_buffer']
|
||||
average_interval = 120000
|
||||
render = 'lines'
|
||||
|
||||
time_limit = -1
|
||||
if len(sys.argv) > 2:
|
||||
time_limit = int(sys.argv[2])
|
||||
|
||||
|
||||
# logfile format:
|
||||
# <time(ms)> <key> <value>
|
||||
# example:
|
||||
# 16434 allocate_buffer: 17
|
||||
for k in keys:
|
||||
|
||||
last_sample = 0
|
||||
average_accumulator = 0
|
||||
average_samples = 0
|
||||
peak = 0
|
||||
|
||||
out = open(k + '.dat', 'wb')
|
||||
eval_average = False
|
||||
if k in average:
|
||||
eval_average = True
|
||||
peak_out = open(k + '_peak.dat', 'wb')
|
||||
|
||||
for line in lines:
|
||||
line = line.split(' ')
|
||||
if len(line) != 3:
|
||||
print(line)
|
||||
continue
|
||||
try:
|
||||
if line[1] == k + ':':
|
||||
if time_limit != -1 and int(line[0]) > time_limit:
|
||||
break
|
||||
time = line[0]
|
||||
value = line[2]
|
||||
if eval_average:
|
||||
while int(time) > last_sample + average_interval:
|
||||
last_sample = last_sample + average_interval
|
||||
if average_samples < 1:
|
||||
average_samples = 1
|
||||
print('%d %f' % (last_sample, average_accumulator / average_samples), file=out)
|
||||
print('%d %f' % (last_sample, peak), file=peak_out)
|
||||
average_accumulator = 0
|
||||
average_samples = 0
|
||||
peak = 0
|
||||
average_accumulator = average_accumulator + float(value)
|
||||
average_samples = average_samples + 1
|
||||
if float(value) > peak:
|
||||
peak = float(value)
|
||||
else:
|
||||
print(time + ' ' + value, end=' ', file=out)
|
||||
except BaseException:
|
||||
print(line)
|
||||
|
||||
out.close()
|
||||
peak_out.close()
|
||||
|
||||
out = open('send_buffer.gnuplot', 'wb')
|
||||
print("set term png size 1200,700", file=out)
|
||||
print('set output "send_buffer.png"', file=out)
|
||||
print('set xrange [0:*]', file=out)
|
||||
print('set xlabel "time (ms)"', file=out)
|
||||
print('set ylabel "bytes (B)"', file=out)
|
||||
print("set style data lines", file=out)
|
||||
print("set key box", file=out)
|
||||
print('plot', end=' ', file=out)
|
||||
for k in keys:
|
||||
if k in average:
|
||||
print(' "%s.dat" using 1:2 title "%s %d seconds average" with %s,' %
|
||||
(k, k, average_interval / 1000., render), end=' ', file=out)
|
||||
print(' "%s_peak.dat" using 1:2 title "%s %d seconds peak" with %s,' %
|
||||
(k, k, average_interval / 1000., render), end=' ', file=out)
|
||||
else:
|
||||
print(' "%s.dat" using 1:2 title "%s" with %s,' % (k, k, render), end=' ', file=out)
|
||||
print('x=0', file=out)
|
||||
out.close()
|
||||
|
||||
os.system('gnuplot send_buffer.gnuplot')
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
lines = open(sys.argv[1], 'rb').readlines()
|
||||
|
||||
# logfile format:
|
||||
# <time(ms)> <key>: <value>
|
||||
# example:
|
||||
# 16434 read cache: 17
|
||||
|
||||
key_order = ['receive buffer', 'send buffer', 'released send buffer', 'posted send buffer',
|
||||
'received send buffer', 'dispatched send buffer', 'queued send buffer',
|
||||
'write cache', 'read cache', 'hash temp']
|
||||
colors = ['30f030', '001070', '101080', '2040a0',
|
||||
'4070d0', '80a0f0', 'f03030',
|
||||
'80f080', 'f08080', '4040ff']
|
||||
|
||||
keys = []
|
||||
fields = {}
|
||||
maximum = {}
|
||||
out = open('disk_buffer_log.dat', 'w+')
|
||||
|
||||
field_sum = {}
|
||||
field_num_samples = {}
|
||||
field_timestamp = {}
|
||||
|
||||
for c in key_order:
|
||||
keys.append(c)
|
||||
fields[c] = 0
|
||||
maximum[c] = 0
|
||||
field_sum[c] = 0
|
||||
field_num_samples[c] = 0
|
||||
field_timestamp[c] = 0
|
||||
|
||||
last_t = 0
|
||||
for l in lines:
|
||||
try:
|
||||
t = int(l[0:l.find(' ')])
|
||||
c = l[l.find(' ') + 1:l.find(':')]
|
||||
n = int(l[l.find(':') + 1:-1])
|
||||
except BaseException:
|
||||
print(l)
|
||||
continue
|
||||
|
||||
if last_t != t:
|
||||
print('%d\t' % last_t, end=' ', file=out)
|
||||
for i in keys:
|
||||
print('%d\t' % maximum[i], end=' ', file=out)
|
||||
print('\n', end=' ', file=out)
|
||||
|
||||
if c not in keys:
|
||||
continue
|
||||
|
||||
field_sum[c] += fields[c] * float(t - field_timestamp[c])
|
||||
field_timestamp[c] = t
|
||||
|
||||
fields[c] = n
|
||||
|
||||
if n > maximum[c]:
|
||||
maximum[c] = n
|
||||
|
||||
if last_t != t:
|
||||
last_t = t
|
||||
maximum = fields
|
||||
|
||||
for i in keys:
|
||||
print('%s: avg: %f' % (i, field_sum[i] / last_t))
|
||||
print()
|
||||
|
||||
out.close()
|
||||
|
||||
out = open('disk_buffer.gnuplot', 'wb')
|
||||
print("set term png size 1200,700", file=out)
|
||||
print('set output "disk_buffer.png"', file=out)
|
||||
print('set xrange [0:*]', file=out)
|
||||
print('set xlabel "time (ms)"', file=out)
|
||||
print('set ylabel "buffers"', file=out)
|
||||
print("set style data lines", file=out)
|
||||
print("set key box", file=out)
|
||||
print('plot', end=' ', file=out)
|
||||
count = 1 + len(keys)
|
||||
keys.reverse()
|
||||
comma = ''
|
||||
for k in keys:
|
||||
expr = "$%d" % count
|
||||
for i in range(2, count):
|
||||
expr += "+$%d" % i
|
||||
count -= 1
|
||||
print(' %s"disk_buffer_log.dat" using 1:(%s) title "%s" with filledcurves x1 lt rgb "#%s"' %
|
||||
(comma, expr, k, colors[count - 1]), end=' ', file=out)
|
||||
comma = ','
|
||||
out.close()
|
||||
|
||||
os.system('gnuplot disk_buffer.gnuplot')
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
# this is meant to parse the dht_lookups.log generated by parse_dht_log.py
|
||||
from __future__ import print_function
|
||||
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# usage: memory.log memory_index.log
|
||||
|
||||
lines = open(sys.argv[1], 'rb').readlines()
|
||||
index = open(sys.argv[2], 'rb').readlines()
|
||||
|
||||
# logfile format:
|
||||
# #<allocation-point> <time(ms)> <key ('A' | 'F')> <address> <size> <total-size> <total-space-time> <peak-total-size>
|
||||
# example:
|
||||
# #12 38 A 0xd902a0 16 16 0 16
|
||||
|
||||
allocation_points_to_print = 30
|
||||
|
||||
|
||||
def print_allocation_point(ap):
|
||||
print('space_time: %d kBms' % (ap['spacetime'] / 1024))
|
||||
print('allocations: %d' % ap['allocations'])
|
||||
print('peak: %d kB' % (ap['peak'] / 1024))
|
||||
print('stack: ')
|
||||
counter = 0
|
||||
for e in ap['stack']:
|
||||
print('#%d %s' % (counter, e))
|
||||
counter += 1
|
||||
|
||||
|
||||
allocation_points = []
|
||||
for line in index:
|
||||
line = line.split('#')
|
||||
line.pop(0)
|
||||
ap = {'allocations': 0, 'peak': 0, 'spacetime': 0, 'allocation_point': len(allocation_points), 'stack': line}
|
||||
allocation_points.append(ap)
|
||||
|
||||
for line in lines:
|
||||
line = line.lstrip('#').rstrip('\n').split(' ')
|
||||
if len(line) != 8:
|
||||
print(line)
|
||||
continue
|
||||
try:
|
||||
ap = int(line[0])
|
||||
allocation_points[ap]['allocations'] += 1
|
||||
allocation_points[ap]['peak'] = int(line[7])
|
||||
allocation_points[ap]['spacetime'] = int(line[6])
|
||||
except Exception as e:
|
||||
print(type(e), e, line)
|
||||
|
||||
print('=== space time ===')
|
||||
|
||||
hot_ap = []
|
||||
allocation_points.sort(key=lambda x: x['spacetime'], reverse=True)
|
||||
counter = 0
|
||||
for ap in allocation_points[0:allocation_points_to_print]:
|
||||
print('== %d ==' % counter)
|
||||
counter += 1
|
||||
print_allocation_point(ap)
|
||||
hot_ap.append(ap['allocation_point'])
|
||||
|
||||
print('=== allocations ===')
|
||||
|
||||
allocation_points.sort(key=lambda x: x['allocations'], reverse=True)
|
||||
for ap in allocation_points[0:allocation_points_to_print]:
|
||||
print_allocation_point(ap)
|
||||
|
||||
print('=== peak ===')
|
||||
|
||||
allocation_points.sort(key=lambda x: x['peak'], reverse=True)
|
||||
for ap in allocation_points[0:allocation_points_to_print]:
|
||||
print_allocation_point(ap)
|
||||
|
||||
# generate graph
|
||||
lines = open(sys.argv[1], 'rb').readlines()
|
||||
|
||||
out = open('memory.dat', 'wb')
|
||||
cur_line = [0] * allocation_points_to_print
|
||||
prev_line = [0] * allocation_points_to_print
|
||||
last_time = 0
|
||||
|
||||
for line in lines:
|
||||
line = line.lstrip('#').rstrip('\n').split(' ')
|
||||
if len(line) != 8:
|
||||
print(line)
|
||||
continue
|
||||
try:
|
||||
time = int(line[1])
|
||||
if time != last_time:
|
||||
print(last_time, '\t', end=' ', file=out)
|
||||
for i in range(allocation_points_to_print):
|
||||
if cur_line[i] == -1:
|
||||
print(prev_line[i], '\t', end=' ', file=out)
|
||||
else:
|
||||
print(cur_line[i], '\t', end=' ', file=out)
|
||||
prev_line[i] = cur_line[i]
|
||||
print(file=out)
|
||||
cur_line = [-1] * allocation_points_to_print
|
||||
last_time = time
|
||||
|
||||
size = int(line[5])
|
||||
ap = int(line[0])
|
||||
if ap in hot_ap:
|
||||
index = hot_ap.index(ap)
|
||||
cur_line[index] = max(cur_line[index], size)
|
||||
|
||||
except Exception as e:
|
||||
print(type(e), e, line)
|
||||
|
||||
out.close()
|
||||
|
||||
out = open('memory.gnuplot', 'wb')
|
||||
print("set term png size 1200,700", file=out)
|
||||
print('set output "memory.png"', file=out)
|
||||
print('set xrange [0:*]', file=out)
|
||||
print('set xlabel "time (ms)"', file=out)
|
||||
print('set ylabel "bytes (B)"', file=out)
|
||||
print("set style data lines", file=out)
|
||||
print("set key box", file=out)
|
||||
print('plot', end=' ', file=out)
|
||||
for k in range(allocation_points_to_print):
|
||||
print(' "memory.dat" using 1:(', end=' ', file=out)
|
||||
for i in range(k, allocation_points_to_print):
|
||||
if i == k:
|
||||
print('$%d' % (i + 2), end=' ', file=out)
|
||||
else:
|
||||
print('+$%d' % (i + 2), end=' ', file=out)
|
||||
print(') title "%d" with filledcurves x1, \\' % k, file=out)
|
||||
print('x=0', file=out)
|
||||
out.close()
|
||||
|
||||
os.system('gnuplot memory.gnuplot')
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import sys
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Copyright (c) 2016, Arvid Norberg
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import os
|
||||
import time
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
||||
import glob
|
||||
import datetime
|
||||
|
|
Loading…
Reference in New Issue