[New] The profiler plugin

148 views
Skip to first unread message

Pierre Raybaut

unread,
Mar 13, 2011, 9:40:13 AM3/13/11
to spyder, eltu...@gmail.com
Hi all,

I've added today to the development version (v2.1.0dev) this new
impressive contribution from Santiago Jaramillo: the profiler plugin.

You may test it by pressing F10 ("Run" menu > "Profile code").
Some features are still missing (but probably not for long):
* profiling results are not saved
* tree items are not yet linked to the editor (to open the
associated file)
* ...
But I'm wasting my time here because the developer of this third-party
plugin has even wrote a documentation:
http://sjara.github.com/spyder-profiler/
As you'll see, the developer is quite open-minded, so I invite you to
participate to this discussion if you have any opinion on this plugin
(bugs, new features, ...).

The original source code repository is here, but note that it's
outdated (since today and changes that were applied to the code for
proper integration in Spyder's current development version):
https://github.com/sjara/spyder-profiler

That is a great contribution, thanks a lot Santiago.

-Pierre

Pierre Raybaut

unread,
Mar 13, 2011, 10:14:43 AM3/13/11
to spyder, eltu...@gmail.com
[Update]

Recent changes:
* fixed expand/collapse bug (expanding/collapsing buttons)
* implemented the editor-link (clicking on a tree item will open
the associated file/line number)

-Pierre

David Verelst

unread,
Mar 13, 2011, 4:08:56 PM3/13/11
to spyd...@googlegroups.com
Very nice indeed!

I had to install python-profiler (ubuntu 10.04) to get spyder running again. I haven't really looked into it yet, but it is a bit strange that profiler was not included in my standard python installation (which is the stock ubuntu one).

Traceback (most recent call last):
  File "/home/dave/Projects/spyderlib/spyderlib/spyder.py", line 1525, in main
    mainwindow = run_spyder(app, options)
  File "/home/dave/Projects/spyderlib/spyderlib/spyder.py", line 1461, in run_spyder
    main.setup()
  File "/home/dave/Projects/spyderlib/spyderlib/spyder.py", line 719, in setup
    for mod in get_spyderplugins_mods(prefix='p_', extension='.py'):
  File "/home/dave/Projects/spyderlib/spyderlib/config.py", line 498, in get_spyderplugins_mods
    for modname in get_spyderplugins(prefix, extension)]
  File "/home/dave/Projects/spyderlib/spyderplugins/p_profiler.py", line 24, in <module>
    from spyderplugins.widgets.profilergui import ProfilerWidget
  File "/home/dave/Projects/spyderlib/spyderplugins/widgets/profilergui.py", line 35, in <module>
    import sys, os, time, pstats
ImportError: No module named pstats


--
You received this message because you are subscribed to the Google Groups "spyder" group.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.


Pierre Raybaut

unread,
Mar 13, 2011, 5:41:05 PM3/13/11
to spyder
On Mar 13, 9:08 pm, David Verelst <david.vere...@gmail.com> wrote:
> Very nice indeed!
>
> I had to install python-profiler (ubuntu 10.04) to get spyder running again.
> I haven't really looked into it yet, but it is a bit strange that profiler
> was not included in my standard python installation (which is the stock
> ubuntu one).

That is very surprising indeed because cProfile and pstats (the Python
profiler modules) are included in the Python standard library.

But I've just read that the Python profiler (actually profile.py)
being not free according to Debian Free Software Guidelines (http://
bugs.debian.org/cgi-bin/bugreport.cgi?bug=293932), they decided to
split the standard library in (at least) two Debian packages (there
could be more, I didn't check).

To avoid this issue, we could consider using hotshot only (hotshot is
in the standard library and really free) instead of the couple
cProfile/pstats but the API seems far from user-friendly, especially
if we can't use pstats to handle the profiling data.

In the meantime, I've added a bugfix to handle the module requirement
in the profiler plugin:
(for the record, it was originally in Santiago's code and when merging
the code I've removed these lines thinking this was not necessary)
http://code.google.com/p/spyderlib/source/detail?r=9dc1c1473a45a22ee4c6b1ff1bdb492d334a134a

Thanks for the feedback,
-Pierre

> Traceback (most recent call last):
>   File "/home/dave/Projects/spyderlib/spyderlib/spyder.py", line 1525, in
> main
>     mainwindow = run_spyder(app, options)
>   File "/home/dave/Projects/spyderlib/spyderlib/spyder.py", line 1461, in
> run_spyder
>     main.setup()
>   File "/home/dave/Projects/spyderlib/spyderlib/spyder.py", line 719, in
> setup
>     for mod in get_spyderplugins_mods(prefix='p_', extension='.py'):
>   File "/home/dave/Projects/spyderlib/spyderlib/config.py", line 498, in
> get_spyderplugins_mods
>     for modname in get_spyderplugins(prefix, extension)]
>   File "/home/dave/Projects/spyderlib/spyderplugins/p_profiler.py", line 24,
> in <module>
>     from spyderplugins.widgets.profilergui import ProfilerWidget
>   File "/home/dave/Projects/spyderlib/spyderplugins/widgets/profilergui.py",
> line 35, in <module>
>     import sys, os, time, pstats
> ImportError: No module named pstats
>

Pierre Raybaut

unread,
Mar 14, 2011, 11:57:23 AM3/14/11
to pmav99, spyd...@googlegroups.com
Of course, you are perfectly right. I didn't know about hotshot being
an obsolete module (as the Python 2.6 doc was referring to it as a
replacement for 'profile').

I always prefer to work with standard modules so let's say with
cProfile/pstats.

Cheers,
Pierre

Le 14 mars 2011 à 10:25, pmav99 <pma...@gmail.com> a écrit :

>
>> To avoid this issue, we could consider using hotshot only (hotshot is
>> in the standard library and really free) instead of the couple
>> cProfile/pstats but the API seems far from user-friendly, especially
>> if we can't use pstats to handle the profiling data.
>

> Hi Pierre,
>
> according to the Python documentation the hotshot module is not
> maintained in Python 2 and it is already removed from Python 3 (http://
> docs.python.org/py3k/library/profile.html). In the long run, wouldn't
> it be better if spyder stayed with standard Library modules?
>
> with regards,
> Panos

Reply all
Reply to author
Forward
0 new messages