Created
January 11, 2018 06:16
-
-
Save clarksun/52a693fe32ee0697a6d4a1070d474776 to your computer and use it in GitHub Desktop.
计算运行时间
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
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