Created
September 30, 2013 12:11
-
-
Save ivanjr0/6762869 to your computer and use it in GitHub Desktop.
Lê o stdin e para cada linha imprime a diferença de tempo.
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
from __future__ import print_function | |
import sys | |
import time | |
def main(): | |
t0 = time.time() | |
while 1: | |
try: | |
line = sys.stdin.readline() | |
now = time.time() | |
d, t0 = now - t0, now | |
print(line, end='') | |
print('+%ss' % (d), file=sys.stderr) | |
except KeyboardInterrupt: | |
break | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment