time operations optimisation
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 12 Aug 2004 13:43:25 +0000 (13:43 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 12 Aug 2004 13:43:25 +0000 (13:43 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@710 04897980-b3bd-0310-b5e0-8ef037075253

12 files changed:
ltt/branches/poly/ltt/time.h
ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c
ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h
ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.h
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c
ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h

index a151505cbf2c12418adb441303d78c4d5efd947a..e350cc998e8ae08ad5ac9527ddd670f971aaee37 100644 (file)
@@ -178,5 +178,25 @@ static inline LttTime ltt_time_div(LttTime t1, double d)
 #endif //0
 }
 
+static inline guint64 ltt_time_to_uint64(LttTime t1)
+{
+  return (guint64)t1.tv_sec*NANOSECONDS_PER_SECOND
+            + (guint64)t1.tv_nsec;
+}
+
+
+#define MAX_TV_SEC_TO_UINT64 0x3FFFFFFFFFFFFFFFULL
+static inline LttTime ltt_time_from_uint64(guint64 t1)
+{
+  /* We lose precision if tv_sec is > than (2^62)-1
+   * */
+  g_assert(t1 <= MAX_TV_SEC_TO_UINT64);
+  if(t1 > MAX_TV_SEC_TO_UINT64)
+    g_warning("Conversion from non precise uint64 to LttTime");
+  LttTime res;
+  res.tv_sec = t1/NANOSECONDS_PER_SECOND;
+  res.tv_nsec = (t1 - res.tv_sec*NANOSECONDS_PER_SECOND);
+  return res;
+}
 
 #endif // LTT_TIME_H
index fe0878be0231232e6772a30ee7f1d642a018873b..ece85cd36ab5ff2238afefcfcf96da6179251300 100644 (file)
@@ -216,7 +216,7 @@ GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
   return control_flow_data->top_widget ;
 }
 
-ProcessList *guicontrolflow_get_process_list
+__inline ProcessList *guicontrolflow_get_process_list
     (ControlFlowData *control_flow_data)
 {
     return control_flow_data->process_list ;
index 86a911c801021a432f8c3fec9b034cafe2e0e9ce..81f79a559c78226e9fc3fd257f7f3f9857ed5287 100644 (file)
@@ -34,7 +34,7 @@ guicontrolflow_destructor_full(ControlFlowData *control_flow_data);
 void
 guicontrolflow_destructor(ControlFlowData *control_flow_data);
 GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data);
-ProcessList *guicontrolflow_get_process_list(ControlFlowData *control_flow_data);
+__inline ProcessList *guicontrolflow_get_process_list(ControlFlowData *control_flow_data);
 
 
 #endif // _CFV_H
index e84cdf5ca5aa40e4c53b4b4a659a9d0f0b0fa96b..c504cf5bc53beda7b66383807a2f44dae12cd7c1 100644 (file)
@@ -742,8 +742,7 @@ GtkWidget *drawing_get_widget(Drawing_t *drawing)
  *
  * Convert from window pixel and time interval to an absolute time.
  */
-//FIXME : could need ceil and floor versions of this function
-void convert_pixels_to_time(
+__inline void convert_pixels_to_time(
     gint width,
     guint x,
     LttTime window_time_begin,
@@ -751,16 +750,18 @@ void convert_pixels_to_time(
     LttTime *time)
 {
   LttTime window_time_interval;
+  guint64 time_ll;
   
   window_time_interval = ltt_time_sub(window_time_end, 
             window_time_begin);
-  *time = ltt_time_mul(window_time_interval, (x/(float)width));
+  time_ll = ltt_time_to_uint64(window_time_interval);
+  time_ll = time_ll * x / width;
+  *time = ltt_time_from_uint64(time_ll);
   *time = ltt_time_add(window_time_begin, *time);
 }
 
-//FIXME : could need ceil and floor versions of this function
 
-void convert_time_to_pixels(
+__inline void convert_time_to_pixels(
     LttTime window_time_begin,
     LttTime window_time_end,
     LttTime time,
@@ -768,7 +769,7 @@ void convert_time_to_pixels(
     guint *x)
 {
   LttTime window_time_interval;
-  double interval_double, time_double;
+  guint64 time_ll, interval_ll;
   
   g_assert(ltt_time_compare(window_time_begin, time) <= 0 &&
            ltt_time_compare(window_time_end, time) >= 0);
@@ -777,11 +778,10 @@ void convert_time_to_pixels(
   
   time = ltt_time_sub(time, window_time_begin);
   
-  /* LttTime to double conversions here should really be under 4000 hours.. */
-  interval_double = ltt_time_to_double(window_time_interval);
-  time_double = ltt_time_to_double(time);
+  time_ll = ltt_time_to_uint64(time);
+  interval_ll = ltt_time_to_uint64(window_time_interval);
 
-  *x = (guint)(time_double/interval_double * width);
+  *x = (guint)(time_ll * width / interval_ll);
   
 }
 
index 30b70f1ea6eb6874c3ba9ca88375d7087df9a07b..bac0b6b8ad7a860b128997b2e3bbcdc04ae701d0 100644 (file)
@@ -134,14 +134,14 @@ void drawing_remove_square(Drawing_t *drawing,
         guint y,
         guint height);
 
-void convert_pixels_to_time(
+__inline void convert_pixels_to_time(
     gint width,
     guint x,
     LttTime window_time_begin,
     LttTime window_time_end,
     LttTime *time);
 
-void convert_time_to_pixels(
+__inline void convert_time_to_pixels(
     LttTime window_time_begin,
     LttTime window_time_end,
     LttTime time,
index a73df51a38b16fbf9688ec00efeb7889cf4af0f9..7284a2e8185889605b2d137c16dca31dd8cc2298 100644 (file)
 #define MAX_PATH_LEN 256
 
 /* drawing hook functions */
-gboolean draw_text( void *hook_data, void *call_data)
+__inline gboolean draw_text( void *hook_data, void *call_data)
 {
   PropertiesText *properties = (PropertiesText*)hook_data;
   DrawContext *draw_context = (DrawContext*)call_data;
@@ -206,7 +206,7 @@ gboolean draw_text( void *hook_data, void *call_data)
 /* To speed up the process, search in already loaded icons list first. Only
  * load it if not present.
  */
-gboolean draw_icon( void *hook_data, void *call_data)
+__inline gboolean draw_icon( void *hook_data, void *call_data)
 {
   PropertiesIcon *properties = (PropertiesIcon*)hook_data;
   DrawContext *draw_context = (DrawContext*)call_data;
@@ -311,7 +311,7 @@ gboolean draw_icon( void *hook_data, void *call_data)
   return 0;
 }
 
-gboolean draw_line( void *hook_data, void *call_data)
+__inline gboolean draw_line( void *hook_data, void *call_data)
 {
   PropertiesLine *properties = (PropertiesLine*)hook_data;
   DrawContext *draw_context = (DrawContext*)call_data;
@@ -358,7 +358,7 @@ gboolean draw_line( void *hook_data, void *call_data)
   return 0;
 }
 
-gboolean draw_arc( void *hook_data, void *call_data)
+__inline gboolean draw_arc( void *hook_data, void *call_data)
 {
   PropertiesArc *properties = (PropertiesArc*)hook_data;
   DrawContext *draw_context = (DrawContext*)call_data;
@@ -434,7 +434,7 @@ gboolean draw_arc( void *hook_data, void *call_data)
   return 0;
 }
 
-gboolean draw_bg( void *hook_data, void *call_data)
+__inline gboolean draw_bg( void *hook_data, void *call_data)
 {
   PropertiesBG *properties = (PropertiesBG*)hook_data;
   DrawContext *draw_context = (DrawContext*)call_data;
index df945e3a44998a24db105a9391c38f9c27593a00..85fc837aac4f41a7479f6ab3aef7593cced6c825 100644 (file)
@@ -268,11 +268,11 @@ void exec_operations( LttvIAttribute *attributes,
  * different items.
  */
 
-gboolean draw_text( void *hook_data, void *call_data);
-gboolean draw_icon( void *hook_data, void *call_data);
-gboolean draw_line( void *hook_data, void *call_data);
-gboolean draw_arc( void *hook_data, void *call_data);
-gboolean draw_bg( void *hook_data, void *call_data);
+__inline gboolean draw_text( void *hook_data, void *call_data);
+__inline gboolean draw_icon( void *hook_data, void *call_data);
+__inline gboolean draw_line( void *hook_data, void *call_data);
+__inline gboolean draw_arc( void *hook_data, void *call_data);
+__inline gboolean draw_bg( void *hook_data, void *call_data);
 
 
 #endif // _DRAW_ITEM_H
index c422e3e9e48ef24172eedad51ae3b3e2f8a6fd2e..23bd9ff7b9b3b6eddc36fc2702f05683de38f12d 100644 (file)
@@ -2733,7 +2733,12 @@ gint update_current_time_hook(void *hook_data, void *call_data)
   
   LttTime time_begin = time_window.start_time;
   LttTime width = time_window.time_width;
-  LttTime half_width = ltt_time_div(width,2.0);
+  LttTime half_width;
+  {
+    guint64 time_ll = ltt_time_to_uint64(width);
+    time_ll = time_ll >> 1; /* divide by two */
+    half_width = ltt_time_from_uint64(time_ll);
+  }
   LttTime time_end = ltt_time_add(time_begin, width);
 
   LttvTracesetContext * tsc =
index df492e727e04f65f6ece4328288aeed83702348d..1cc7f1392b965dfd6cb8629cc02861b53847fd1f 100644 (file)
@@ -32,7 +32,7 @@
  *                       Methods to synchronize process list                 *
  *****************************************************************************/
 
-static guint get_cpu_number_from_name(GQuark name);
+static __inline guint get_cpu_number_from_name(GQuark name);
   
 /* Enumeration of the columns */
 enum
@@ -575,7 +575,7 @@ guint processlist_get_height(ProcessList *process_list)
 }
 
 
-gint processlist_get_process_pixels(  ProcessList *process_list,
+__inline gint processlist_get_process_pixels(  ProcessList *process_list,
           guint pid, guint cpu, LttTime *birth, guint trace_num,
           guint *y,
           guint *height,
@@ -616,7 +616,7 @@ gint processlist_get_process_pixels(  ProcessList *process_list,
 }
 
 
-gint processlist_get_pixels_from_data(  ProcessList *process_list,
+__inline gint processlist_get_pixels_from_data(  ProcessList *process_list,
           ProcessInfo *process_info,
           HashedProcessData *hashed_process_data,
           guint *y,
@@ -638,9 +638,8 @@ gint processlist_get_pixels_from_data(  ProcessList *process_list,
 
 }
 
-static guint get_cpu_number_from_name(GQuark name)
+static __inline guint get_cpu_number_from_name(GQuark name)
 {
-  /* remember / */
   const gchar *string;
   char *begin;
   guint cpu;
index 39b496d5508fde80613b35d43d366a18cabc17b5..808e5fab4d4e5656aa2fae5d22a066edec142085 100644 (file)
@@ -102,12 +102,12 @@ int processlist_remove(ProcessList *process_list, guint pid, guint cpu,
 guint processlist_get_height(ProcessList *process_list);
 
 // Returns 0 on success
-gint processlist_get_process_pixels(ProcessList *process_list,
+__inline gint processlist_get_process_pixels(ProcessList *process_list,
         guint pid, guint cpu, LttTime *birth, guint trace_num,
         guint *y, guint *height,
         HashedProcessData **hashed_process_data);
 
-gint processlist_get_pixels_from_data(  ProcessList *process_list,
+__inline gint processlist_get_pixels_from_data(  ProcessList *process_list,
           ProcessInfo *process_info,
           HashedProcessData *hashed_process_data,
           guint *y,
index ea848ada2accc84d2682d8b650dbba36c03487a5..51fb7b2d8062d52b32b00ee7248088ee104a30f6 100644 (file)
@@ -914,7 +914,7 @@ void lttvwindow_events_request_remove_all(Tab       *tab,
  * @return time window.
  */
 
-TimeWindow lttvwindow_get_time_window(Tab *tab)
+__inline TimeWindow lttvwindow_get_time_window(Tab *tab)
 {
   return tab->time_window;
   
index 25cb2a7feb10cf9e6e8e25205115690975c258ab..18e5853e0481853811987b09441aed082e2fb021 100644 (file)
@@ -662,7 +662,7 @@ void lttvwindow_events_request_remove_all(Tab            *tab,
  * @return the current tab's time interval.
  */
 
-TimeWindow lttvwindow_get_time_window(Tab *tab);
+__inline TimeWindow lttvwindow_get_time_window(Tab *tab);
 
 
 /**
This page took 0.031341 seconds and 4 git commands to generate.