Skip to content

Instantly share code, notes, and snippets.

@martijnbastiaan
Created January 15, 2021 20:52
Show Gist options
  • Save martijnbastiaan/94cc171f836fb359734aa376c81d0e8b to your computer and use it in GitHub Desktop.
Save martijnbastiaan/94cc171f836fb359734aa376c81d0e8b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import glob
import dateutil.parser
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import sys
def get_points():
for fname in sorted(glob.glob("*.log")):
f = open(fname, "r")
t1 = dateutil.parser.parse(f.readline())
baseline_bytes = int(f.readline())
t2 = dateutil.parser.parse(f.readline())
stack_bytes = int(f.readline())
t3 = dateutil.parser.parse(f.readline())
baseline_speed = baseline_bytes / (t2 - t1).total_seconds()
stack_speed = stack_bytes / (t3 - t2).total_seconds()
yield (t1, baseline_speed / 1024 / 1024, stack_speed / 1024 / 1024)
print("timestamp,ubuntu archive,github")
for point in get_points():
print("%s,%.2f,%.2f" % point)
(timestamps, baseline_mibs, stack_mibs) = zip(*get_points())
print("-------------------")
print(" min max")
print("Baseline: %05.2f %05.2f" % (min(*baseline_mibs), max(*baseline_mibs)))
print(("Stack: %05.2f %05.2f" % (min(*stack_mibs), max(*stack_mibs)))
fig = plt.figure()
splt = fig.add_subplot(211)
splt.plot(timestamps, baseline_mibs)
splt.plot(timestamps, stack_mibs)
splt.set_ylabel('MiB/s')
plt.gcf().autofmt_xdate()
axes = plt.gca()
axes.set_ylim([0,None])
myFmt = mdates.DateFormatter('%Y-%m-%d %H:%M')
axes.xaxis.set_major_formatter(myFmt)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment