Skip to content

Instantly share code, notes, and snippets.

@ivanjr0
Created September 30, 2013 12:11
Show Gist options
  • Save ivanjr0/6762869 to your computer and use it in GitHub Desktop.
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.
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