0

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!

2 Answers2

1

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.

roippi
  • 25,533
  • 4
  • 48
  • 73
  • This isn't something that can be optimized, right? Kind of just works in the background? At almost ten minutes of total operating time, this(along with my main CUDA kernel) really slows my model to the point where I cannot iterate it. – Hair of Slytherin Oct 09 '13 at 11:33
  • Yea, I still feel like I need to know what exactly this mainloop is doing. I'm using EZGUI in my program to grab some initial parameters and everything, but check out this cProfile output from a really long run of my code. I don't see the connection between Tkinter and how my program solves lots of differential equations simultaneously. – Hair of Slytherin Oct 11 '13 at 19:53
-1

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.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135