parse-clientscale-logs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. import numpy as np
  3. import re
  4. import sys
  5. # Print the mean and stddev of the floats in the list of data
  6. def printstats(data):
  7. mean = np.mean(data)
  8. stddev = np.std(data)
  9. print(f",{mean:.3f},{stddev:.3f}", end='')
  10. if __name__ == "__main__":
  11. times = {}
  12. for line in sys.stdin.readlines():
  13. if matches := \
  14. re.match(r'(\d+) (\d+) \d+ (\d+\.?\d*) (\d+\.?\d*) (\d+\.?\d*)',
  15. line):
  16. groups = matches.groups()
  17. label, send_time, fetch_time, tot_time = \
  18. (int(groups[0]), int(groups[1])), float(groups[2]), \
  19. float(groups[3]), float(groups[4])
  20. if label not in times:
  21. times[label] = [ [], [], [] ]
  22. times[label][0].append(send_time)
  23. times[label][1].append(fetch_time)
  24. times[label][2].append(tot_time)
  25. print("users,batches,send_mean,send_stddev,fetch_mean,fetch_stddev,tot_mean,tot_stddev")
  26. for k in sorted(times.keys()):
  27. print(k[0], k[1], sep=',', end='')
  28. for data in times[k]:
  29. printstats(data)
  30. print('')