4

I am trying to line profile some code I wrote in Cython. But I cannot get it to work.

I have tried to follow all the steps given in How to profile cython functions line-by-line

But I dont get any timings out as a result. What I done is posted here:

I am using python 3.6 and Cython 0.25.2

What I try to do:

First I run:

python setup.py build_ext --inplace

In setup.py I have added:

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

and to the extension I added,

define_macros=[('CYTHON_TRACE', '1')]

In the script runMIcython.pyx, I have added:

@cython.profile(True)
@cython.linetrace(True)
@cython.binding(True)

In an ipython shell, I then try to run (takes about 1 min):

%load_ext line_profiler
import line_profiler 
import runMolecularIntegrals  
profile = line_profiler.LineProfiler(runMolecularIntegrals.runCythonIntegrals)
profile.runcall(runMolecularIntegrals.runIntegrals) 
profile.print_stats()

But the output I get is:

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):
4

0 回答 0