Profiling Cython classes

105 views
Skip to first unread message

Ethan Van Andel

unread,
Jun 7, 2011, 4:43:34 PM6/7/11
to cython-users
I have some system of cython files for a simulation I'm working on.
All the work is done by these cython files, but the user interface is
provided by a couple of python wrapper scripts. When I try to profile
my code I get a single monolithic entry for my wrapper script followed
by lots of fuzz entries. Ex:

python -m cProfile run.py
...
compilation stuff
...
runtime stuff
...
2023705 function calls (1979558 primitive calls) in 106.180
CPU seconds

Ordered by: internal time
List reduced from 3201 to 100 due to restriction <100>

ncalls tottime percall cumtime percall
filename:lineno(function)
1 100.606 100.606 102.020 102.020 {run}
6 3.056 0.509 3.056 0.509 {posix.waitpid}
207315 0.540 0.000 0.540 0.000 arrayprint.py:
463(_formatInteger)
5000 0.245 0.000 1.188 0.000 arrayprint.py:
305(_formatArray)
...

Now all my cython files have the "# cython: profile=True" flag at the
top (as does run.py just in case), so I would expect the sort of
function-by-function breakdown that I got before moving to cython.

Do I need to change something, or am I trying to do something that's
impossible?

Robert Bradshaw

unread,
Jun 7, 2011, 4:51:41 PM6/7/11
to cython...@googlegroups.com

Setting "#cython: profile=True" at the top should just work, though in
older versions of Cython it was too picky about the whitespace in
commend directives. Try setting it to an illegal value (like foo) and
making sure it complains to see that it's actually picking it up. That
failing, post a link to your sources (preferably with the .c and
annotated .html files as well).

- Robert

Ethan Van Andel

unread,
Jun 9, 2011, 12:25:48 PM6/9/11
to cython-users
It turns out that our lab was running .11.2 which doesn't have the
profiling abilities. We've upgraded now and everything works.

Thanks,

Ethan

On Jun 7, 4:51 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Robert Bradshaw

unread,
Jun 9, 2011, 12:58:27 PM6/9/11
to cython...@googlegroups.com
Ah, that would explain it. 0.11.2 is pretty old, just out of curiosity
why was that the default?

Ethan Van Andel

unread,
Jun 13, 2011, 10:58:53 AM6/13/11
to cython-users
0.11.2 is the default for lucid ubuntu which our lab is running. I
think the sysadmin just grabbed the default package (not
unreasonable).

On Jun 9, 12:58 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:
> Ah, that would explain it. 0.11.2 is pretty old, just out of curiosity
> why was that the default?
>

Robert Bradshaw

unread,
Jun 13, 2011, 6:26:42 PM6/13/11
to cython...@googlegroups.com
Ah. The real question is how to update all these old package repositories...
Reply all
Reply to author
Forward
0 new messages