parse-corescale-logs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. ncores = None
  13. for line in sys.stdin.readlines():
  14. if corematch := \
  15. re.match(r'cores: (\d+)', line):
  16. ncores = int(corematch.group(1))
  17. if matches := \
  18. re.match(r'(\d+) (\d+) \d+ (\d+\.?\d*) (\d+\.?\d*) (\d+\.?\d*)',
  19. line):
  20. groups = matches.groups()
  21. label, send_time, fetch_time, tot_time = \
  22. (int(groups[0]), int(groups[1]), ncores), float(groups[2]), \
  23. float(groups[3]), float(groups[4])
  24. if label not in times:
  25. times[label] = [ [], [], [] ]
  26. times[label][0].append(send_time)
  27. times[label][1].append(fetch_time)
  28. times[label][2].append(tot_time)
  29. print("users,batches,ncores,send_mean,send_stddev,fetch_mean,fetch_stddev,tot_mean,tot_stddev")
  30. for k in sorted(times.keys()):
  31. print(k[0], k[1], k[2], sep=',', end='')
  32. for data in times[k]:
  33. printstats(data)
  34. print('')