我是python中line_profiler包的新手。我是否错误地读取了结果,或者下面输出中的组件不应该达到1.67554秒?相反,它们加起来为3.918秒(2426873微秒+ 1491105微秒)。谢谢!
# test.py
import numpy as np
def tf():
arr = np.random.randn(3000,6000)
np.where(arr>1,arr,np.nan)
import test
%lprun -f test.tf test.tf()
Timer unit: 4.27654e-07 s
File: test.py
Function: tf at line 9
Total time: 1.67554 s
Line # Hits Time Per Hit % Time Line Contents
==============================================================
9 def tf():
10 1 2426873 2426873.0 61.9 arr = np.random.randn(3000,6000)
11 1 1491105 1491105.0 38.1 np.where(arr>1,arr,np.nan)
答案 0 :(得分:2)
时间:执行计时器中行所花费的总时间。在表格之前的标题信息中,您将看到一行"定时器单元:" 将转换系数设为秒数。在不同的系统上可能会有所不同。
强调我的。您的输出显示每个定时器单元约为0.428微秒。如果将单位乘以 Timer单位值,则总计匹配:
>>> unit = 4.27654e-07
>>> 2426873 * unit + 1491105 * unit
1.675538963612