diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-02-01 11:21:01 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-02-02 10:46:48 -0500 |
commit | 4194ebf9df4bc2e1395859e9de5b003d0008cafa (patch) | |
tree | 5ab04a06ce43722567f5c268f49e5bb9f0ca378c | |
parent | 5beceaae5c57dcf1b92d1def5954ac331a19a63a (diff) | |
download | kutter-4194ebf9df4bc2e1395859e9de5b003d0008cafa.tar.gz kutter-4194ebf9df4bc2e1395859e9de5b003d0008cafa.tar.xz kutter-4194ebf9df4bc2e1395859e9de5b003d0008cafa.zip |
graphstats: Display host buffer stats in graph
Prune host buffer stats near the start and end of the print. Graph
the remaining buffer stats.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rwxr-xr-x | scripts/graphstats.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/graphstats.py b/scripts/graphstats.py index 64ef37e9..7600ee52 100755 --- a/scripts/graphstats.py +++ b/scripts/graphstats.py @@ -27,10 +27,32 @@ def parse_log(logname): f.close() return out +def find_print_restarts(data): + last_print_time = 0. + print_resets = [] + for d in data: + print_time = float(d.get('print_time', last_print_time)) + if print_time < last_print_time: + print_resets.append(d['#sampletime']) + last_print_time = 0. + else: + last_print_time = print_time + sample_resets = {} + for d in data: + st = d['#sampletime'] + while print_resets and st > print_resets[0]: + print_resets.pop(0) + if not print_resets: + break + if st + 2. * MAXBUFFER > print_resets[0]: + sample_resets[st] = 1 + return sample_resets + def plot_mcu(data, maxbw, outname): # Generate data for plot basetime = lasttime = data[0]['#sampletime'] lastbw = float(data[0]['bytes_write']) + float(data[0]['bytes_retransmit']) + sample_resets = find_print_restarts(data) times = [] bwdeltas = [] loads = [] @@ -49,7 +71,7 @@ def plot_mcu(data, maxbw, outname): load = 0. pt = float(d['print_time']) hb = float(d['buffer_time']) - if pt <= 2*MAXBUFFER or hb >= MAXBUFFER: + if pt <= 2. * MAXBUFFER or hb >= MAXBUFFER or st in sample_resets: hb = 0. else: hb = 100. * (MAXBUFFER - hb) / MAXBUFFER @@ -67,7 +89,7 @@ def plot_mcu(data, maxbw, outname): ax1.set_ylabel('Usage (%)') ax1.plot_date(times, bwdeltas, 'g', label='Bandwidth') ax1.plot_date(times, loads, 'r', label='MCU load') - #ax1.plot_date(times, hostbuffers, 'c', label='Host buffer') + ax1.plot_date(times, hostbuffers, 'c', label='Host buffer') ax1.legend() ax1.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M')) #plt.gcf().autofmt_xdate() |