Question

Sorted by total time, the second longest executing function is "{built-in method mainloop}" ? I looked at the same entry with pstats_viewer.py and clicked it and it says :

Function Exclusive time Inclusive time  Primitive calls Total calls Exclusive per call  Inclusive per call

Tkinter.py:359:mainloop 0.00s   561.03s (26.3%) 1   1   0.00s   561.03s

What does this mean?

Edit

Here's part of the cProfile output from a longer run of my code. The more ODE's I solve, the more time is devoted to mainloop. This is crazy! I thought that my runtime was getting killed by either branch divergence in my CUDA kernel or Host-GPU memory transfers. God, I'm a horrible programmer!

How have I made Tkinter take so much of my runtime?

Here is a snippet of my cProfile from a longer run of my code.  That Tkinter.py mainloop is costing me hours of runtime!

Était-ce utile?

La solution

mainloop is the event loop in Tkinter. It waits for events and processes them as they come in.

This is a recurring thing that you will see in all GUIs as well as any other event-driven frameworks like Twisted or Tornado.

Autres conseils

First of all, it's a lot easier to see if you change tabs to spaces, as in:

Function                    Exclusive time  Inclusive time  Primitive calls  Total calls    Exclusive per call     Inclusive per call

Tkinter.py:359:mainloop     0.00s           561.03s (26.3%)       1              1               0.00s                  561.03s

Exclusive time means time that the program counter was in that routine. For a top-level routine you would expect this to be practically zero.

Inclusive time means including time in all routines that the routine calls. For a top-level routine you would expect this to be practically 100%. (I don't understand what that 26.3% means.)

If you are trying to get more speed, what you need to do is find activity that 1) has a high percent inclusive time, and 2) that you can do something about.

This link shows the method I use.

After you speed something up, you will still find things that take a high percent inclusive time, but the overall elapsed time will be less. Eventually you will get to a point where some things still take a high percent, but you can no longer figure out how to improve it.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top