Ask Your Question
3

Profiling code in the Sage notebook

asked 2011-08-06 07:12:47 -0500

benjaminfjones gravatar image

How can one profile Sage code in the notebook? I know you can use %prun <command> on the command line, but I understand this is a feature of IPython so it's not available in the notebook. I've looked (and searched) through the reference manual, sage-devel, and asksage to no avail.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2016-04-04 14:54:29 -0500

tmonteil gravatar image

There is now a thematic tutorial listing profiling tools for Sage: http://doc.sagemath.org/html/en/thema...

edit flag offensive delete link more
1

answered 2012-01-17 02:36:21 -0500

pang gravatar image

Just for reference, here's a snippet on how to use cProfile:

import cProfile, pstats
cProfile.runctx("your_function(10000)", globals(), locals(), DATA + "Profile.prof")
s = pstats.Stats(DATA + "Profile.prof")
s.strip_dirs().sort_stats("time").print_stats()
edit flag offensive delete link more
1

answered 2011-08-06 11:42:33 -0500

benjaminfjones gravatar image

I found that the Python profiler will do the job: http://docs.python.org/library/profil...

It would be cool if there was an easy way to get the notebook to display some kind of data visualization based on the statistics from the python profiler, like the way one can see lines highlighted and colored in the notebook when working with Cython code.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-08-06 07:12:47 -0500

Seen: 840 times

Last updated: Apr 04 '16