Re: button.cc opengl application much slower than button.c and button.pl



I solved this one  I think. I noticed that the gears example is just as fast on each one.

So I looked and found that the button example uses timeouts while
the gears uses timers.

I found that if I just speeded up the timeout on the button from 10 seconds
to 3 seconds for gtkglextmm it was just as fast as 10 seconds on gtkglext. And
at 1 second it was faster. 

So it turns out to be something about how the timout is implemented in gtkmm and (perhaps  how it interacts with other concurrent functions that are running.

thanks,

Mitchell
 












On 13:55 Wed 09 Jan     , Mitchell Laks wrote:
> Hi,
> 
> I have been playing with gtkglextmm-1.2 and gtkglext and Gtk2::GLext.  I notice that
> when i run the example application button.cc which comes with gtkglextmm it is 3 times slower
> than the C version in gtkglext-1.2, which runs at about the same speed as the perl version.
> 
> This application builds a Torus which jumps and spins. The jumping and spinning is painfully slow
> in the gtkglextmm version.
> 
> I tried to profile it with gprof but I really don't know what I am doing :(. I can attach the output of a 20 minute run
> 
> 
> I noticed that the original cpp code keeps reallocating the glwindown and glcontext for each expost event
> which seems wasteful so I moved that to a global variable so that it didnt need to be reallocated, but that
> didnt have much benefit. Are there any other ideas?
> 
> 
> here is the gprof output before I did the global glwindow and glcontext variables: 
> Flat profile:
> 
> Each sample counts as 0.01 seconds.
>   %   cumulative   self              self     total
>  time   seconds   seconds    calls  Ts/call  Ts/call  name
>  50.00      0.01     0.01                             GLScene::on_expose_event(_GdkEventExpose*)
>  25.00      0.01     0.01                             GLToggleButton::on_toggled()
>  25.00      0.02     0.01                             GLScene::on_visibility_notify_event(_GdkEventVisibility*)
>   0.00      0.02     0.00   352659     0.00     0.00  Glib::RefPtr<Gdk::GL::Window>::operator->() const
>   0.00      0.02     0.00   140969     0.00     0.00  Glib::RefPtr<Gdk::Window>::~RefPtr()
>   0.00      0.02     0.00   140969     0.00     0.00  Glib::RefPtr<Gdk::Window>::operator->() const
>   0.00      0.02     0.00    70533     0.00     0.00  Gtk::GL::Widget<Gtk::GL::DrawingArea>::get_gl_window()
>   0.00      0.02     0.00    70533     0.00     0.00  Gtk::GL::Widget<Gtk::GL::DrawingArea>::get_gl_context()
>   0.00      0.02     0.00    70533     0.00     0.00  Glib::RefPtr<Gdk::GL::Window>::~RefPtr()
>   0.00      0.02     0.00    70533     0.00     0.00  Glib::RefPtr<Gdk::GL::Context>::~RefPtr()
>   0.00      0.02     0.00    70485     0.00     0.00  GLScene::invalidate()
>   0.00      0.02     0.00    70484     0.00     0.00  GLScene::on_timeout()
>   0.00      0.02     0.00    70484     0.00     0.00  GLScene::update()
>   0.00      0.02     0.00    70484     0.00     0.00  sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> >::operator()() const
>   0.00      0.02     0.00    70484     0.00     0.00  sigc::limit_reference<GLScene, true>::invoke() const
>   0.00      0.02     0.00    70484     0.00     0.00  sigc::bound_mem_functor0<bool, GLScene>::operator()() const
>   0.00      0.02     0.00    70484     0.00     0.00  std::sin(float)
>   0.00      0.02     0.00       28     0.00     0.00  sigc::limit_reference<GLScene, true>::visit() const
>   0.00      0.02     0.00       16     0.00     0.00  sigc::internal::with_type_pointer<true, sigc::trackable, sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> >::execute_(sigc::trackable const&, sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&)
>   0.00      0.02     0.00       16     0.00     0.00  sigc::internal::with_type_pointer<true, sigc::trackable, sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind> >::execute_(sigc::trackable const&, sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind> const&)
>   0.00      0.02     0.00       16     0.00     0.00  sigc::internal::slot_do_bind::operator()(sigc::trackable const*) const
>   0.00      0.02     0.00       16     0.00     0.00  sigc::internal::slot_do_unbind::operator()(sigc::trackable const*) const
>   0.00      0.02     0.00       16     0.00     0.00  void sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>::operator()<sigc::trackable>(sigc::trackable const&) const
>   0.00      0.02     0.00       16     0.00     0.00  void sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>::operator()<sigc::trackable>(sigc::trackable const&) const
>   0.00      0.02     0.00       14     0.00     0.00  void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, GLScene, true>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::limit_reference<GLScene, true> const&)
>   0.00      0.02     0.00       14     0.00     0.00  void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, sigc::bound_mem_functor0<bool, GLScene> >(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> > const&)
>   0.00      0.02     0.00       14     0.00     0.00  void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, sigc::trackable>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::trackable const&)
>   0.00      0.02     0.00       14     0.00     0.00  void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::intector0(GLScene&, bool (GLScene::*)())
>   0.00      0.02     0.00        7     0.00     0.00  sigc::slot<bool, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot<sigc::bound_mem_functor0<bool, GLScene> >(sigc::bound_mem_functor0<bool, GLScene> const&)
>   0.00      0.02     0.00        7     0.00     0.00  sigc::slot<bool, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::~slot()
>   0.00      0.02     0.00        7     0.00     0.00  sigc::slot0<bool>::slot0<sigc::bound_mem_functor0<bool, GLScene> >(sigc::bound_mem_functor0<bool, GLScene> const&)
>   0.00      0.02     0.00        7     0.00     0.00  sigc::slot0<bool>::~slot0()
>   0.00      0.02     0.00        7     0.00     0.00  sigc::bound_mem_functor0<bool, GLScene> sigc::mem_fun<bool, GLScene, GLScene>(GLScene&, bool (GLScene::*)())
>   0.00      0.02     0.00        7     0.00     0.00  sigc::internal::slot_call0<sigc::bound_mem_functor0<bool, GLScene>, bool>::address()
>   0.00      0.02     0.00        7     0.00     0.00  sigc::internal::typed_slot_rep<sigc::bound_mem_functor0<bool, GLScene> >::typed_slot_rep(sigc::bound_mem_functor0<bool, GLScene> const&)
>   0.00      0.02     0.00        7     0.00     0.00  sigc::internal::typed_slot_rep<sigc::bound_mem_functor0<bool, GLScene> >::typed_slot_rep(sigc::internal::typed_slot_rep<sigc::bound_mem_functor0<bool, GLScene> > const&)
>   0.00      0.02     0.00        7     0.00     0.00  GLScene::timeout_remove()
>   0.00      0.02     0.00        3     0.00     0.00  Glib::RefPtr<Gdk::GL::Config>::~RefPtr()
>   0.00      0.02     0.00        2     0.00     0.00  Gdk::GL::operator|s accounted
>  seconds   for by this function and those listed above it.
> 
>  self      the number of seconds accounted for by this
> seconds    function alone.  This is the major sort for this
>            listing.
> 
> calls      the number of times this function was invoked, if
>            this function is profiled, else blank.
> 
>  self      the average number of milliseconds sp 0.00    0.00   70531/70533       GLScene::on_expose_event(_GdkEventExpose*) [1]
> [15]     0.0    0.00    0.00   70533         Gtk::GL::Widget<Gtk::GL::DrawingArea>::get_gl_context() [15]
> -----------------------------------------------
>                 0.00    0.00       1/70533       GLScene::on_configure_event(_GdkEventConfigure*) [102]
>                 0.00    0.00       1/70533       GLScene::on_realize() [99]
>                 0.00    0.00   70531/70533       GLScene::on_expose_event(_GdkEventExpose*) [1]
> [16]     0.0    0.00    0.00   70533         Glib::RefPtr<Gdk::GL::Window>::~RefPtr() [16]
> -----------------------------------------------
>                 0.00    0.00       1/70533       GLScene::on_configure_event(_GdkEventConfigure*) [102]
>                 0.00    0.00       1/70533       GLScene::on_realize() [99]
>                 0.00    0.00   70531/70533       GLScene::on_expose_event(_GdkEventExpose*) [1]
> [17]     0.0    0.00    0.00   70533         Glib::RefPtr<Gdk::GL::Context>::~RefPtr() [17]
> -----------------------------------------------
>                 0.00    0.00       1/70485       GLScene::toggle_animation() [81]
>                 0.00    0.00   70484/70485       GLScene::on_timeout() [19]
> [18]     0.0    0.00    0.00   70485         GLScene::invalidate() [18]
>                 0.00    0.00   70485/140969      Glib::RefPtr<Gdk::Window>::operator->() const [13]
>                 0.00    0.00   70485/140969      Glib::RefPtr<Gdk::Window>::~RefPtr() [12]
> -----------------------------------------------
>                 0.00    0.00   70484/70484       sigc::bound_mem_functor0<bool, GLScene>::operator()() const [23]
> [19]     0.0    0.00    0.00   70484         GLScene::on_timeout() [19]
>                 0.00    0.00   70484/70484       std::sin(float) [24]
>                 0.00    0.00   70484/70485       GLScene::invalidate() [18]
>                 0.00    0.00   70484/70484       GLScene::update() [20]
> ----------------0.00    0.00      14/28          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>, GLScene, true>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::sld_target<sigc::trackable*, sigc::internal::slot_do_unbind>::operator()<sigc::trackable>(sigc::trackable const&) const [31]
>                 0.00    0.00      16/16          sigc::internal::with_type_pointer<true, sigc::trackable, sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind> >::execute_(sigc::trackable const&, sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind> const&) [27]
> -----------------------------------------------
>                 0.00    0.00      14/14          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, bool, GLScene>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::bound_mem_functor0<bool, GLScene> const&) [35]
> [32]     0.0    0.00    0.00      14         void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, GLScene, true>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::limit_reference<GLScene, true> const&) [32]
>                 0.00    0.00      14/28          sigc::limit_reference<GLScene, true>::visit() const [25]
>                 0.00    0.00      14/14          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, sigc::trackable>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::trackable const&) [34]
> -----------------------------------------------
>                 0.00    0.00      14/14          void sigc::visit_each_type<sigc::trackable*, sigc::internal::slot_do_bind, sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> > >(sigc::internal::slot_do_bind const&, sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> > const&) [41]
> [33]     0.0    0.00    0.00      14         void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, sigc::bound_mem_functor0<bool, GLScene> >(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> > const&) [33]
>                 0.00    0.00      14/14          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, bool, GLScene>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::bound_mem_functor0<bool, GLScene> const&) [35]
> -----------------------------------------------
>                 0.00    0.00      14/14          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, GLScene, true>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::limit_reference<GLScene, true> const&) [32]
> [34]     0.0    0.00    0.00      14         void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, sigc::trackable>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::trackable const&) [34]
>                 0.00    0.00      16/16          void sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>::operator()<sigc::trackable>(sigc::trackable const&) const [30]
> -----------------------------------------------
>                 0.00    0.00      14/14          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, sigc::bound_mem_functor0<bool, GLScene> >(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> const&, sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> > const&) [33]
> [35]     0.0    0.00    0.00      14         void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind>, bool, GLScene>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_bind> cl, GLScene> const&) [39]
>                 0.00    0.00      14/14          void sigc::visit_each<sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind>, GLScene, true>(sigc::internal::limit_derived_target<sigc::trackable*, sigc::internal::slot_do_unbind> const&, sigc::limit_reference<GLScene, true> const&) [36]
> ---------------------------------::trackable*, sigc::internal::slot_do_bind, sigc::adaptor_functor<sigc::bound_mem_functor0<bool, GLScene> > >(sigc::internal::slot_do_bind const&, sigc::adaptor_functor<sigc::bound_memor0(GLScene&, bool (GLScene::*)()) [54]
> [53]     0.0    0.00    0.00       7         sigc::limit_reference<GLScene, true>::limit_reference(GLScene&) [53]
> -----------------------------------------------
>                 0.00    0.00       7/7           sdaptor_functor<sigc::bound_mem_functor0<bool, GLScene> >::adaptor_functor(sigc::bound_mem_functor0<bool, GLScene> const&) [52]
>                 0.00    0.00       7/14          s        0.00    0.00       1/1           Gtk::GL::Widget<Gtk::GL::DrawingArea>::set_gl_capability(Glib::RefPtr<Gdk::GL::Config const> const&, bool, int) [71]
> -----------------------------------------------
>                 0.00    ib::RefPtr<Gdk::GL::Config const> const&, bool, int) [70]
> -----------------------------------------------
>                 0.00    0.00       1/1           GLTog  The child's index
>                 number is printed after it.  If the child is a
>                 member of a cycle, the cycle number is printed
>      l, sigc::nil>::slot<sigc::bound_mem_functor0<bool, GLScene> >(sigc::bound_mem_functor0<bool, GLScene> const&) [83] 
> 
> **********************
> whereas this is the output for the gtkglext c version
> 
> Flat profile:
> 
> Each sample counts as 0.01 seconds.
>  no time accumulated
> 
>   %   cumulative   self              self     total
>  time   seconds   seconds    calls  Ts/call  Ts/call  name
>   0.00      0.00     0.00        2     0.00     0.00  timeout_remove
>   0.00      0.00     0.00        1     0.00     0.00  create_gl_toggle_button
>   0.00      0.00     0.00        1     0.00     0.00  timeout_add
> 
>  %         the percentage of the total running time of the
> time       program used by this function.
> 
> cumulative a running sum of the number of seconds accounted
>  seconds   for by this function and those listed above it.
> 
>  self      the number of seconds accounted for by this
> seconds    function alone.  This is the major sort for this
>            listing.
> 
> calls      the number of times this function was invoked, if
>            this function is profiled, else blank.
> 
>  self      the average number of milliseconds spent in this
> ms/call    function per call, if this function is profiled,
>            else blank.
> 
>  total     the average number of milliseconds spent in this
> ms/call    function and its descendents per call, if this
>            function is profiled, else blank.
> 
> name       the name of the function.  This is the minor sort
>            for this listing. The index shows the location of
>            the function in the gprof listing. If the index is
>            in parenthesis it shows where it would appear in
>            the gprof listing if it were to be printed.
> 
> 
>                      Call graph (explanation follows)
> 
> 
> granularity: each sample hit covers 4 byte(s) no time propagated
> 
> index % time    self  children    called     name
>                 0.00    0.00       1/2           unrealize [18]
>                 0.00    0.00       1/2           toggle_animation [16]
> [1]      0.0    0.00    0.00       2         timeout_remove [1]
> -----------------------------------------------
>                 0.00    0.00       1/1           main [12]
> [2]      0.0    0.00    0.00       1         create_gl_toggle_button [2]
> -----------------------------------------------
>                 0.00    0.00       1/1           map_event [13]
> [3]      0.0    0.00    0.00       1         timeout_add [3]
> -----------------------------------------------
> 
>  This table describes the call tree of the program, and was sorted by
>  the total amount of time spent in each function and its children.
> 
>  Each entry in this table consists of several lines.  The line with the
>  index number at the left hand margin lists the current function.
>  The lines above it list the functions that called this function,
>  and the lines below it list the functions this one called.
>  This line lists:
>      index      A unique number given to each element of the table.
>                 Index numbers are sorted numerically.
>                 The index number is printed next to every function name so
>                 it is easier to look up where the function in the table.
> 
>      % time     This is the percentage of the `total' time that was spent
>                 in this function and its children.  Note that due to
>                 different viewpoints, functions excluded by options, etc,
>                 these numbers will NOT add up to 100%.
> 
>      self       This is the total amount of time spent in this function.
> 
>      children   This is the total amount of time propagated into this
>                 function by its children.
> 
>      called     This is the number of times the function was called.
>                 If the function called itself recursively, the number
>                 only includes non-recursive calls, and is followed by
>                 a `+' and the number of recursive calls.
> 
>      name       The name of the current function.  The index number is
>                 printed after it.  If the function is a member of a
>                 cycle, the cycle number is printed between the
>                 function's name and the index number.
> 
> 
>  For the function's parents, the fields have the following meanings:
> 
>      self       This is the amount of time that was propagated directly
>                 from the function into this parent.
> 
>      children   This is the amount of time that was propagated from
>                 the function's children into this parent.
> 
>      called     This is the number of times this parent called the
>                 function `/' the total number of times the function
>                 was called.  Recursive calls to the function are not
>                 included in the number after the `/'.
> 
>      name       This is the name of the parent.  The parent's index
>                 number is printed after it.  If the parent is a
>                 member of a cycle, the cycle number is printed between
>                 the name and the index number.
> 
>  If the parents of the function cannot be determined, the word
>  `<spontaneous>' is printed in the `name' field, and all the other
>  fields are blank.
> 
>  For the function's children, the fields have the following meanings:
> 
>      self       This is the amount of time that was propagated directly
>                 from the child into the function.
> 
>      children   This is the amount of time that was propagated from the
>                 child's children to the function.
> 
>      called     This is the number of times the function called
>                 this child `/' the total number of times the child
>                 was called.  Recursive calls by the child are not
>                 listed in the number after the `/'.
> 
>      name       This is the name of the child.  The child's index
>                 number is printed after it.  If the child is a
>                 member of a cycle, the cycle number is printed
>                 between tht name and the index number.
> 
> If there are any cycles (circles) in the call graph, there is an
>  entry for the cycle-as-a-whole.  This entry shows who called the
>  cycle (as parents) and the members of the cycle (as children.)
>  The `+' recursive calls entry shows the number of function calls that
>  were internal to the cycle, and the calls entry for each member shows,
>  for that member, how many times it was called from other members of
>  the cycle.
> 
> 
> 
> Index by function name
> 
> 
> 
> 
> 
>  [2] create_gl_toggle_button (button.c) [3] timeout_add (button.c) [1] timeout_remove (button.c)
> 
> 
> Thanks,
> Mitchell
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]