线路分析 Cython 0.25

Eri*_*ren 5 python cython line-profiler

我正在尝试对我在 Cython 中编写的一些代码进行分析。但我无法让它发挥作用。

我尝试按照如何逐行分析 cython 函数中给出的所有步骤进行操作

但结果我没有得到任何计时。我所做的发布在这里:

我正在使用 python 3.6 和 Cython 0.25.2

我尝试做的事情:

首先我运行:

python setup.py build_ext --inplace
Run Code Online (Sandbox Code Playgroud)

在 setup.py 中我添加了:

import Cython.Compiler.Options

Cython.Compiler.Options.get_directive_defaults()['profile'] = True
Cython.Compiler.Options.get_directive_defaults()['linetrace'] = True
Cython.Compiler.Options.get_directive_defaults()['binding'] = True
Run Code Online (Sandbox Code Playgroud)

以及我添加的扩展,

define_macros=[('CYTHON_TRACE', '1')]
Run Code Online (Sandbox Code Playgroud)

在脚本 runMIcython.pyx 中,我添加了:

@cython.profile(True)
@cython.linetrace(True)
@cython.binding(True)
Run Code Online (Sandbox Code Playgroud)

在 ipython shell 中,我尝试运行(大约需要 1 分钟):

%load_ext line_profiler
import line_profiler 
import runMolecularIntegrals  
profile = line_profiler.LineProfiler(runMolecularIntegrals.runCythonIntegrals)
profile.runcall(runMolecularIntegrals.runIntegrals) 
profile.print_stats()
Run Code Online (Sandbox Code Playgroud)

但我得到的输出是:

Line #      Hits         Time  Per Hit   % Time  Line Contents  
==============================================================  
    10                                           cpdef 
runCythonIntegrals(int [:,:] basisidx, double [:,:] basisfloat, int [:,:] basisint, double[:,:] input, double[:,:] Na, double[:,:] S, double[:,:] T, double[:,:,:,:] ERI):
Run Code Online (Sandbox Code Playgroud)