Profiling python 2.3

Discussion in 'Python' started by Kenneth Johansson, Jan 27, 2005.

  1. I wonder what would be a good way to profile a python program where the
    main thread starts two worker threads that do all the work.

    I get no infomation at all from the threads.

    I tried to use profile.run as the first thing in the new thread and the
    thread starts and works fine but when it exits I get this error

    File "/usr/lib/python2.3/profile.py", line 71, in run
    prof = prof.run(statement)
    File "/usr/lib/python2.3/profile.py", line 403, in run
    return self.runctx(cmd, dict, dict)
    File "/usr/lib/python2.3/profile.py", line 409, in runctx
    exec cmd in globals, locals
    TypeError: exec: arg 1 must be a string, file, or code object



    The main problem I have is that when I add a small function to a program
    the resulting code takes longer than it should. The program takes
    about 80% normally and end up taking more than 100%. I did a small test
    of the new funtions and when I run that alone it only takes 20%-25% so
    the result sould not take more than 50% and now I need to know where the
    time is spent.
    Kenneth Johansson, Jan 27, 2005
    #1
    1. Advertising

  2. Stephen Kellett, Jan 28, 2005
    #2
    1. Advertising

  3. On Fri, 28 Jan 2005 10:02:33 +0000, Stephen Kellett wrote:

    > In message <ctbora$84d$>, Kenneth
    > Johansson <> writes
    >>I wonder what would be a good way to profile a python program where the
    >>main thread starts two worker threads that do all the work.
    >>
    >>I get no infomation at all from the threads.

    >
    > Python Performance Validator (beta)
    >
    > http://www.softwareverify.com/pythonPerformanceValidator/index.html
    >
    > Stephen


    I develop on linux.

    Nice to see I do not have to recompile and relink to use the tool that's a
    real problem with other python stuff ;)
    Kenneth Johansson, Jan 28, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joerg Beyer
    Replies:
    0
    Views:
    738
    Joerg Beyer
    Sep 17, 2003
  2. Joerg Beyer
    Replies:
    3
    Views:
    537
    Joerg Beyer
    Sep 18, 2003
  3. Replies:
    6
    Views:
    476
  4. Dave

    Profiling Python using gprof

    Dave, Oct 11, 2005, in forum: Python
    Replies:
    0
    Views:
    952
  5. =?ISO-8859-1?Q?Andreas_R=F8sdal?=

    Performance profiling Python code

    =?ISO-8859-1?Q?Andreas_R=F8sdal?=, Mar 24, 2006, in forum: Python
    Replies:
    2
    Views:
    1,083
    Felipe Almeida Lessa
    Mar 24, 2006
Loading...

Share This Page