FAQ
Hi,

I am using hotshot module to profile my python function.

I used the details from (
http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/
).

The function I profile is a recursive one and I am getting the following
error,

"ProfilerError: profiler already active"

I guess this is due to the recursive call to the profiling function.

I would like to get some suggestions.

--
Regards,
S.Selvam
SG E-ndicus Infotech Pvt Ltd.
http://e-ndicus.com/

" I am because we are "
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110522/25e70f9b/attachment.html>

Search Discussions

  • Gabriel Genellina at May 25, 2011 at 8:50 am
    En Sun, 22 May 2011 10:42:08 -0300, Selvam <s.selvamsiva at gmail.com>
    escribi?:
    I am using hotshot module to profile my python function.

    I used the details from (
    http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/
    ).

    The function I profile is a recursive one and I am getting the following
    error,

    "ProfilerError: profiler already active"

    I guess this is due to the recursive call to the profiling function.

    I would like to get some suggestions.
    The recursive call inside your function should call the undecorated
    function, not the decorated function again. Decorator syntax is not
    convenient anymore.

    Using the same names as in the recipe example:


    # a recursive function
    def my_slow_function(n):
    ...
    return my_slow_function(n-1)


    my_profiled_slow_function = hotshotit(my_slow_function)
    my_profiled_slow_function(n)


    This works, in the sense that it does not raise ProfileError anymore.
    Interpreting profile data is up to you...


    --
    Gabriel Genellina
  • Selvam at May 26, 2011 at 8:00 am

    On Wed, May 25, 2011 at 2:20 PM, Gabriel Genellina wrote:

    En Sun, 22 May 2011 10:42:08 -0300, Selvam <s.selvamsiva at gmail.com>
    escribi?:


    I am using hotshot module to profile my python function.
    I used the details from (

    http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/
    ).

    The function I profile is a recursive one and I am getting the following
    error,

    "ProfilerError: profiler already active"

    I guess this is due to the recursive call to the profiling function.

    I would like to get some suggestions.
    The recursive call inside your function should call the undecorated
    function, not the decorated function again. Decorator syntax is not
    convenient anymore.

    Using the same names as in the recipe example:


    # a recursive function
    def my_slow_function(n):
    ...
    return my_slow_function(n-1)


    my_profiled_slow_function = hotshotit(my_slow_function)
    my_profiled_slow_function(n)


    This works, in the sense that it does not raise ProfileError anymore.
    Interpreting profile data is up to you...


    Thanks Gabriel, it makes more sense !
    --
    Gabriel Genellina

    --
    http://mail.python.org/mailman/listinfo/python-list


    --
    Regards,
    S.Selvam
    SG E-ndicus Infotech Pvt Ltd.
    http://e-ndicus.com/

    " I am because we are "
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20110526/718ffb96/attachment.html>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMay 22, '11 at 1:42p
activeMay 26, '11 at 8:00a
posts3
users2
websitepython.org

2 users in discussion

Selvam: 2 posts Gabriel Genellina: 1 post

People

Translate

site design / logo © 2022 Grokbase