[pygtk] Gtk main-iteration seems slow

Stuart Axon stuaxo2 at yahoo.com
Wed Apr 22 06:28:31 WST 2009


Hi,
  I've been doing some basic profiling on shoebot, which uses pygtk + cairo, it seems that gtk-main_iteration seems to take the most amount of time.  
I did some benchmarks (drawing 100 frames, with main_iteration and without).

  Time per frame
  0.203320000172   gtk.main_iteration
  0.210910000801   gtk.main_iteration(block = False)
  0.0180599999428  No gtk.main_iteration

I've listed the code of the main drawing loop below, is there a way I can up the framerate to something closer to 60, not 5 ?
(on the other hand should gtk.main_iteration really be this slow??)

            while 1:
                # increase bot frame count
                self.bot.next_frame()
                # redraw canvas
                self.drawingarea.redraw()
                
                # respect framerate
                completion_time = time()
                exc_time = completion_time - start_time
                start_time = completion_time
                sleep(1. / (self.bot.framerate - exc_time))
                
                while gtk.events_pending():
                    gtk.main_iteration()



      


More information about the pygtk mailing list