accelerate double useage for time
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 13 Aug 2004 19:41:14 +0000 (19:41 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 13 Aug 2004 19:41:14 +0000 (19:41 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@729 04897980-b3bd-0310-b5e0-8ef037075253

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/detailedevents/events.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c

index ec4d134baf97d051ae2d3d7b87c29f837a5943b4..642328e9001d9ac0c5ad08e5a98e4a16748e432d 100644 (file)
@@ -85,10 +85,12 @@ static inline double ltt_time_to_double(LttTime t1)
    *
    * So we have 53-30 = 23 bits left for tv_sec.
    * */
+#ifdef EXTRA_CHECK
   g_assert(t1.tv_sec <= MAX_TV_SEC_TO_DOUBLE);
   if(t1.tv_sec > MAX_TV_SEC_TO_DOUBLE)
     g_warning("Precision loss in conversion LttTime to double");
-  return (double)t1.tv_sec + (double)t1.tv_nsec / NANOSECONDS_PER_SECOND;
+#endif //EXTRA_CHECK
+  return ((double)t1.tv_sec * NANOSECONDS_PER_SECOND) + (double)t1.tv_nsec;
 }
 
 
@@ -102,12 +104,14 @@ static inline LttTime ltt_time_from_double(double t1)
    *
    * So we have 53-30 = 23 bits left for tv_sec.
    * */
+#ifdef EXTRA_CHECK
   g_assert(t1 <= MAX_TV_SEC_TO_DOUBLE);
   if(t1 > MAX_TV_SEC_TO_DOUBLE)
     g_warning("Conversion from non precise double to LttTime");
+#endif //EXTRA_CHECK
   LttTime res;
-  res.tv_sec = t1;
-  res.tv_nsec = (t1 - res.tv_sec) * NANOSECONDS_PER_SECOND;
+  res.tv_sec = t1/(double)NANOSECONDS_PER_SECOND;
+  res.tv_nsec = (t1 - (res.tv_sec*NANOSECONDS_PER_SECOND));
   return res;
 }
 
@@ -188,9 +192,11 @@ static inline LttTime ltt_time_from_uint64(guint64 t1)
 {
   /* We lose precision if tv_sec is > than (2^62)-1
    * */
+#ifdef EXTRA_CHECK
   g_assert(t1 <= MAX_TV_SEC_TO_UINT64);
   if(t1 > MAX_TV_SEC_TO_UINT64)
     g_warning("Conversion from non precise uint64 to LttTime");
+#endif //EXTRA_CHECK
   LttTime res;
   res.tv_sec = t1/NANOSECONDS_PER_SECOND;
   res.tv_nsec = (t1 - res.tv_sec*NANOSECONDS_PER_SECOND);
index ece85cd36ab5ff2238afefcfcf96da6179251300..01189e552bb4ed4fef67be2b9ca85e5917a73253 100644 (file)
@@ -211,7 +211,8 @@ guicontrolflow_destructor(ControlFlowData *control_flow_data)
  
 }
 
-GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data)
+__inline GtkWidget *guicontrolflow_get_widget(
+                                     ControlFlowData *control_flow_data)
 {
   return control_flow_data->top_widget ;
 }
index 81f79a559c78226e9fc3fd257f7f3f9857ed5287..35119ab370c0d577b365f1b3445577a30c9c7dd9 100644 (file)
@@ -33,8 +33,10 @@ void
 guicontrolflow_destructor_full(ControlFlowData *control_flow_data);
 void
 guicontrolflow_destructor(ControlFlowData *control_flow_data);
-GtkWidget *guicontrolflow_get_widget(ControlFlowData *control_flow_data);
-__inline ProcessList *guicontrolflow_get_process_list(ControlFlowData *control_flow_data);
+__inline GtkWidget *guicontrolflow_get_widget(
+                                       ControlFlowData *control_flow_data);
+__inline ProcessList *guicontrolflow_get_process_list(
+                                       ControlFlowData *control_flow_data);
 
 
 #endif // _CFV_H
index 01d4260dbd24966f640b4c912747f7cd50267df7..aaf8b03005d0b47d0ac6600a745db1ef50f717c9 100644 (file)
@@ -935,13 +935,13 @@ __inline void convert_pixels_to_time(
     LttTime *time)
 {
   LttTime window_time_interval;
-  guint64 time_ll;
+  double time_d;
   
   window_time_interval = ltt_time_sub(window_time_end, 
             window_time_begin);
-  time_ll = ltt_time_to_uint64(window_time_interval);
-  time_ll = time_ll * x / width;
-  *time = ltt_time_from_uint64(time_ll);
+  time_d = ltt_time_to_double(window_time_interval);
+  time_d = time_d / (double)width * (double)x;
+  *time = ltt_time_from_double(time_d);
   *time = ltt_time_add(window_time_begin, *time);
 }
 
@@ -954,23 +954,23 @@ __inline void convert_time_to_pixels(
     guint *x)
 {
   LttTime window_time_interval;
-  guint64 time_ll, interval_ll;
-  
+  double time_d, interval_d;
+#ifdef EXTRA_CHECK 
   g_assert(ltt_time_compare(window_time_begin, time) <= 0 &&
            ltt_time_compare(window_time_end, time) >= 0);
-  
+#endif //EXTRA_CHECK
   window_time_interval = ltt_time_sub(window_time_end,window_time_begin);
   
   time = ltt_time_sub(time, window_time_begin);
   
-  time_ll = ltt_time_to_uint64(time);
-  interval_ll = ltt_time_to_uint64(window_time_interval);
+  time_d = ltt_time_to_double(time);
+  interval_d = ltt_time_to_double(window_time_interval);
   
-  if(interval_ll == 0) {
-    g_assert(time_ll == 0);
+  if(interval_d == 0.0) {
+    g_assert(time_d == 0.0);
     *x = 0;
   } else {
-    *x = (guint)(time_ll * width / interval_ll);
+    *x = (guint)(time_d / interval_d * (double)width);
   }
   
 }
index 85f241486e4ae4ebcafaee048489d47ddee4f792..f96d14a996bc5c36462b182ef96ab69564d0afe3 100644 (file)
@@ -415,7 +415,7 @@ gui_events(Tab *tab)
   end = ltt_time_sub(time_span.end_time, time_span.start_time);
 
   event_viewer_data->vadjust_c->upper =
-              ltt_time_to_double(end) * NANOSECONDS_PER_SECOND;
+              ltt_time_to_double(end);
 
   event_viewer_data->append = TRUE;
 
@@ -973,7 +973,7 @@ static void get_data_wrapped(double time_value, gint list_height,
   remove_all_items_from_queue(event_viewer_data->event_fields_queue);
   end.tv_sec = G_MAXULONG;
   end.tv_nsec = G_MAXULONG;
-  time = ltt_time_from_double(time_value / NANOSECONDS_PER_SECOND);
+  time = ltt_time_from_double(time_value);
   start = ltt_time_add(time_span.start_time, time);
   event_viewer_data->previous_value = time_value;
   get_events(event_viewer_data, start, end, RESERVE_SMALL_SIZE,&size);
@@ -1034,9 +1034,9 @@ static void get_data_wrapped(double time_value, gint list_height,
   event_fields = (EventFields*)g_list_nth_data(first,event_number);
   if(!event_fields) event_fields = (EventFields*)g_list_nth_data(first,0);       
   time = ltt_time_sub(event_fields->time, time_span.start_time);
-  event_viewer_data->vadjust_c->value = ltt_time_to_double(time) * NANOSECONDS_PER_SECOND;
+  event_viewer_data->vadjust_c->value = ltt_time_to_double(time);
   //gtk_adjustment_set_value(event_viewer_data->vadjust_c, 
-  //                         ltt_time_to_double(time) * NANOSECONDS_PER_SECOND);
+  //                         ltt_time_to_double(time));
   //g_signal_stop_emission_by_name(G_OBJECT(event_viewer_data->vadjust_c), "value-changed");
   event_viewer_data->previous_value = event_viewer_data->vadjust_c->value;
   //gtk_adjustment_value_changed(event_viewer_data->vadjust_c);
@@ -1361,9 +1361,9 @@ gboolean update_current_time(void * hook_data, void * call_data)
   count = 0;
       }
       t = ltt_time_sub(data->time, time_span.start_time);
-      event_viewer_data->vadjust_c->value = ltt_time_to_double(t) * NANOSECONDS_PER_SECOND;
+      event_viewer_data->vadjust_c->value = ltt_time_to_double(t);
       //gtk_adjustment_set_value(event_viewer_data->vadjust_c, 
-      //                         ltt_time_to_double(t) * NANOSECONDS_PER_SECOND);
+      //                         ltt_time_to_double(t));
       //g_signal_stop_emission_by_name(G_OBJECT(event_viewer_data->vadjust_c), "value-changed");
       event_viewer_data->previous_value = event_viewer_data->vadjust_c->value;
       insert_data_into_model(event_viewer_data,j, j+event_viewer_data->num_visible_events); 
@@ -1371,7 +1371,7 @@ gboolean update_current_time(void * hook_data, void * call_data)
 
     }else{//the event is not in the buffer
       LttTime start = ltt_time_sub(*current_time, time_span.start_time);
-      double position = ltt_time_to_double(start) * NANOSECONDS_PER_SECOND;
+      double position = ltt_time_to_double(start);
       gtk_adjustment_set_value(event_viewer_data->vadjust_c, position);
     }
   }
@@ -1398,7 +1398,7 @@ gboolean traceset_changed(void * hook_data, void * call_data)
   event_viewer_data->append = TRUE;
 
   end = ltt_time_sub(time_span.end_time, time_span.start_time);
-  event_viewer_data->vadjust_c->upper = ltt_time_to_double(end) * NANOSECONDS_PER_SECOND;
+  event_viewer_data->vadjust_c->upper = ltt_time_to_double(end);
   g_signal_emit_by_name(event_viewer_data->vadjust_c, "value-changed");
   //  event_viewer_data->vadjust_c->value = 0;
 
index 2f42d26398a1051ede60d028fdf4a50828278ea6..e0e677fceb3db170f724b80d2902ac6c29d95416 100644 (file)
@@ -3454,18 +3454,15 @@ void time_change_manager               (Tab *tab,
                "lower",
                  0.0, /* lower */
                "upper",
-               ltt_time_to_double(upper) 
-                 * NANOSECONDS_PER_SECOND, /* upper */
+               ltt_time_to_double(upper), /* upper */
                "step_increment",
                ltt_time_to_double(new_time_window.time_width)
-                             / SCROLL_STEP_PER_PAGE
-                             * NANOSECONDS_PER_SECOND, /* step increment */
+                             / SCROLL_STEP_PER_PAGE, /* step increment */
                "page_increment",
-               ltt_time_to_double(new_time_window.time_width) 
-                 * NANOSECONDS_PER_SECOND, /* page increment */
+               ltt_time_to_double(new_time_window.time_width), 
+                                                     /* page increment */
                "page_size",
-               ltt_time_to_double(new_time_window.time_width) 
-                 * NANOSECONDS_PER_SECOND, /* page size */
+               ltt_time_to_double(new_time_window.time_width), /* page size */
                NULL);
   gtk_adjustment_changed(adjustment);
 
@@ -3473,13 +3470,12 @@ void time_change_manager               (Tab *tab,
  //              "value",
  //              ltt_time_to_double(
  //               ltt_time_sub(start_time, time_span.start_time))
- //                  * NANOSECONDS_PER_SECOND, /* value */
+ //                 , /* value */
  //              NULL);
   //gtk_adjustment_value_changed(adjustment);
   gtk_range_set_value(GTK_RANGE(tab->scrollbar),
                ltt_time_to_double(
-                ltt_time_sub(start_time, time_span.start_time))
-                   * NANOSECONDS_PER_SECOND /* value */);
+                ltt_time_sub(start_time, time_span.start_time)) /* value */);
 
   /* set the time bar. */
   /* start seconds */
@@ -3841,7 +3837,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
     LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
   TimeInterval time_span = tsc->time_span;
 
-  time = ltt_time_add(ltt_time_from_double(value/NANOSECONDS_PER_SECOND),
+  time = ltt_time_add(ltt_time_from_double(value),
                       time_span.start_time);
 
   new_time_window.start_time = time;
@@ -3849,7 +3845,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
   page_size = adjust->page_size;
 
   new_time_window.time_width = 
-    ltt_time_from_double(page_size/NANOSECONDS_PER_SECOND);
+    ltt_time_from_double(page_size);
 
 
   time_change_manager(tab, new_time_window);
@@ -3864,7 +3860,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
   //time = ltt_time_sub(time_span->end_time, time_span->start_time);
   //time = ltt_time_mul(time, (float)ratio);
   //time = ltt_time_add(time_span->start_time, time);
-  time = ltt_time_add(ltt_time_from_double(value/NANOSECONDS_PER_SECOND),
+  time = ltt_time_add(ltt_time_from_double(value),
                       time_span.start_time);
 
   time_window.start_time = time;
@@ -3872,7 +3868,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
   page_size = adjust->page_size;
 
   time_window.time_width = 
-    ltt_time_from_double(page_size/NANOSECONDS_PER_SECOND);
+    ltt_time_from_double(page_size);
   //time = ltt_time_sub(time_span.end_time, time);
   //if(ltt_time_compare(time,time_window.time_width) < 0){
   //  time_window.time_width = time;
index aa42477282a62f4e02ea39d2b548958f76c151a3..e0700de2250493bbc1f2f7b774e6cf8ab369d7b7 100644 (file)
@@ -759,24 +759,24 @@ void lttvwindow_report_time_window(Tab *tab,
                "upper",
                ltt_time_to_double(
                  ltt_time_sub(time_span.end_time, time_span.start_time)) 
-                 * NANOSECONDS_PER_SECOND, /* upper */
+                 , /* upper */
                "step_increment",
                ltt_time_to_double(time_window->time_width)
                              / SCROLL_STEP_PER_PAGE
-                             * NANOSECONDS_PER_SECOND, /* step increment */
+                            , /* step increment */
                "page_increment",
                ltt_time_to_double(time_window->time_width) 
-                 * NANOSECONDS_PER_SECOND, /* page increment */
+                 , /* page increment */
                "page_size",
                ltt_time_to_double(time_window->time_width) 
-                 * NANOSECONDS_PER_SECOND, /* page size */
+                 , /* page size */
                NULL);
   gtk_adjustment_changed(adjustment);
 
   //g_object_set(G_OBJECT(adjustment),
   //             "value",
   //             ltt_time_to_double(time_window->start_time) 
-  //               * NANOSECONDS_PER_SECOND, /* value */
+  //               , /* value */
   //               NULL);
   /* Note : the set value will call set_time_window if scrollbar value changed
    */
@@ -784,7 +784,7 @@ void lttvwindow_report_time_window(Tab *tab,
                            ltt_time_to_double(
                              ltt_time_sub(time_window->start_time,
                                           time_span.start_time))
-                           * NANOSECONDS_PER_SECOND);
+                           );
 #endif //0
 }
 
This page took 0.030679 seconds and 4 git commands to generate.