My program is a visualizer that is constantly updating the display. I am trying to optimize it to increase the framerate, and my largest cost is gtk._gtk.main:
ncalls tottime percall cumtime percall filename:lineno(function)
1 9.159 9.159 45.476 45.476 {gtk._gtk.main}
868 8.146 0.009 9.884 0.011 xyz.py:291(gfx_transform_queue)
868 7.705 0.009 12.657 0.015 xyz.py:322(gfx_draw_queue)
868 3.886 0.004 7.755 0.009 xyz.py:240(gfx_queue_atoms)
868000 2.638 0.000 4.952 0.000 xyz.py:365(gfx_draw_circle)
7027010 2.111 0.000 2.111 0.000 xyz.py:314(cmp_queue)
1736000 2.015 0.000 2.015 0.000 {method 'draw_arc' of 'gtk.gdk.Drawable' objects}
869844 1.728 0.000 1.728 0.000 {numpy.core._dotblas.dot}
868 1.635 0.002 3.746 0.004 {sorted}
869872 1.261 0.000 1.261 0.000 {numpy.core.multiarray.array}
933 1.100 0.001 1.100 0.001 {method 'get_pointer' of 'gtk.gdk.Window' objects}
Is this reasonable behavior, or is it possible I am doing something wrong to make gtk.main suck up a lot of time?
You’re interpreting the profiling data wrong.
gtk.main() is really just running your program as the user interacts with it. What you’re seeing is that it takes time to run your program, not gtk.main() itself.