Last active
December 16, 2015 02:39
-
-
Save inactivist/5363910 to your computer and use it in GitHub Desktop.
"Quick and dirty" Python script for counting the lines per second pulled from stdin.
This file contains hidden or 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/python | |
"""Print stats about stdin per-line timings.""" | |
import signal | |
import sys | |
import time | |
start = time.time() | |
count = 0 | |
try: | |
for line in sys.stdin: | |
count += 1 | |
except KeyboardInterrupt: | |
pass | |
end = time.time() | |
et = end - start | |
lps = count / et | |
print "Elapsed time = %f, lines = %d, lps = %f" % (et, count, lps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good !
what about this version: