Skip to content

Instantly share code, notes, and snippets.

@kotnik
Created November 5, 2014 13:57
Show Gist options
  • Save kotnik/589eb16f55cef46eef3a to your computer and use it in GitHub Desktop.
Save kotnik/589eb16f55cef46eef3a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import fileinput
import json
import statistics
def pr_line(i, j, k):
print("%s %s %s" % (i.ljust(40), j.rjust(10), k.rjust(10)))
def main():
events = {}
for line in fileinput.input():
data = json.loads(line)
method = data["method"]["fullname"]
duration = data["timings"]["duration_sec"]
if not events.get(method):
events[method] = []
events[method].append(duration)
pr_line("METHOD", "AVG", "STDDEV")
for event, timings in events.items():
mean = "%.4f" % statistics.mean(timings)
stdev = "%.4f" % statistics.stdev(timings)
pr_line(event, mean, stdev)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment