Created
June 10, 2014 19:48
-
-
Save atiaxi/b0b06ea25def9789a4bf to your computer and use it in GitHub Desktop.
Time analyzer
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 python | |
import sys | |
def main(): | |
total = 0 | |
entries = 0 | |
outlier_total = 0 | |
outlier_entries = 0 | |
with open(sys.argv[1], "r") as infile: | |
for line in infile: | |
words = line.split(" ") | |
elapsed = words[-1] | |
stanzas = (float(e) for e in elapsed.split(":")) | |
hours, minutes, seconds = stanzas | |
seconds += minutes * 60 | |
seconds += hours * 3600 | |
total += seconds | |
entries += 1 | |
if seconds >= 1: | |
outlier_total += seconds | |
outlier_entries += 1 | |
print "%d entries, %d total seconds" % (entries, total) | |
print "Average: %f per entry" % (total / float(entries)) | |
if outlier_total > 0: | |
print "Outliers: %d entries, %d total seconds" % (outlier_entries, outlier_total) | |
print "Average: %f per entry" % (outlier_total / float(outlier_entries)) | |
else: | |
print "No entries > 1 sec" | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment