Profiling programs/scripts?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skanemupp@yahoo.se

    Profiling programs/scripts?

    how do i profile a program? i found out that there are some profilers
    included in the standard library but couldnt really figure out how to
    access/use them

  • Aaron Watters

    #2
    Re: Profiling programs/scripts?

    On Apr 11, 2:49 pm, skanem...@yahoo .se wrote:
    how do i profile a program? i found out that there are some profilers
    included in the standard library but couldnt really figure out how to
    access/use them
    I put this at the bottom of my main module:

    === cut
    if __name__=="__ma in__":
    try:
    from cProfile import run
    except:
    from profile import run
    run("tests()")
    === cut

    Here tests() is the function I want to profile. The cProfile
    module, when available is better than the older profile module,
    but it's only available in very recent Python installations.
    The profile "run" function will run the tests function and print
    a report on the timings and counts it found.

    More info here:


    -- Aaron Watters
    ===

    Comment

    Working...