diff gui/src/octave-adapter/octave-link.cc @ 14754:626a8ff2fe8c gui

The GUI now shows performance information in the status bar of the GUI (ie. how much overhead it causes in the octave thread compares to the terminal version). * main-window: Added update timer. Added slot to update status bar with performance info. * octave-link:: Added performance information struct and timing calls.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sat, 09 Jun 2012 19:59:43 +0200
parents c6135951bc18
children a565c560e654
line wrap: on
line diff
--- a/gui/src/octave-adapter/octave-link.cc
+++ b/gui/src/octave-adapter/octave-link.cc
@@ -20,8 +20,10 @@
 
 int octave_readline_hook ()
 {
+  octave_link::instance ()->entered_readline_hook ();
   octave_link::instance ()->generate_events ();
   octave_link::instance ()->process_events ();
+  octave_link::instance ()->finished_readline_hook ();
   return 0;
 }
 
@@ -36,6 +38,7 @@
 octave_link::octave_link ()
 {
   _event_queue_mutex = new octave_mutex ();
+  _performance_information_mutex = new octave_mutex ();
   _last_working_directory = "";
   _debugging_mode_active = false;
 }
@@ -63,6 +66,7 @@
 void
 octave_link::generate_events ()
 {
+  _next_performance_information.generate_events_start = clock ();
   std::string current_working_directory = octave_env::get_current_directory ();
   if (current_working_directory != _last_working_directory)
     {
@@ -83,12 +87,15 @@
             _octave_event_listener->quit_debug_mode ();
         }
     }
+  _next_performance_information.generate_events_stop = clock ();
 }
 
 void
 octave_link::process_events ()
 {
+  _next_performance_information.process_events_start = clock ();
   _event_queue_mutex->lock ();
+  _next_performance_information.event_queue_size = _event_queue.size ();
   while (_event_queue.size () > 0)
     {
       octave_event * e = _event_queue.front ();
@@ -99,6 +106,7 @@
         e->reject ();
     }
   _event_queue_mutex->unlock ();
+  _next_performance_information.process_events_stop = clock ();
 }
 
 void
@@ -132,3 +140,25 @@
   if (_octave_event_listener)
     _octave_event_listener->about_to_exit ();
 }
+
+void
+octave_link::entered_readline_hook ()
+{ }
+
+void
+octave_link::finished_readline_hook ()
+{
+  _performance_information_mutex->lock ();
+  _performance_information = _next_performance_information;
+  _performance_information_mutex->unlock ();
+}
+
+octave_link::performance_information
+octave_link::get_performance_information ()
+{
+  performance_information p;
+  _performance_information_mutex->lock ();
+  p = _performance_information;
+  _performance_information_mutex->unlock ();
+  return p;
+}