Skip to content

Instantly share code, notes, and snippets.

@clarksun
Created January 11, 2018 06:16
Show Gist options
  • Save clarksun/52a693fe32ee0697a6d4a1070d474776 to your computer and use it in GitHub Desktop.
Save clarksun/52a693fe32ee0697a6d4a1070d474776 to your computer and use it in GitHub Desktop.
计算运行时间
import time
class ET:
def __init__(self):
self.start_time = time.time()
def __call__(self):
return time.time() - self.start_time
et = ET()
.....
print(f'elapsed time: {et():.2f}')
# from https://github.com/writeson/async_python_programming_presentation/blob/master/code/example_3.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment