Ask Your Question

Profiling code in the Sage notebook

asked 2011-08-06 14:12:47 +0200

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

answered 2016-04-04 21:54:29 +0200

tmonteil gravatar image

There is now a thematic tutorial listing profiling tools for Sage:

edit flag offensive delete link more

answered 2011-08-06 18:42:33 +0200

benjaminfjones gravatar image

I found that the Python profiler will do the job:

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

answered 2012-01-17 09:36:21 +0200

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 + "")
s = pstats.Stats(DATA + "")
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

1 follower


Asked: 2011-08-06 14:12:47 +0200

Seen: 1,388 times

Last updated: Apr 04 '16