|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
以下代码返回了一个非常小的数:1.9e-06,这是为什么?
- def calc(func):
- import time
- start = time.perf_counter()
- func
- return time.perf_counter() - start
- if __name__ == "__main__":
- def test(return_value):
- import time
- time.sleep(10)
- return return_value
- print(calc(test("This is the return value.")))
复制代码
- def calc(func, *args, **kw):
- import time
- start = time.perf_counter()
- print(func(*args, **kw))
- return time.perf_counter()
- if __name__ == "__main__":
- def test(return_value):
- import time
- time.sleep(10)
- return return_value
- print(calc(test, "This is the return value."))
复制代码
|
|