Created
November 5, 2014 13:57
-
-
Save kotnik/589eb16f55cef46eef3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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