From c74e0cf9bdbda21d13d48be89bc9fd3e257c9b9e Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 13 Aug 2004 19:41:14 +0000 Subject: [PATCH] accelerate double useage for time git-svn-id: http://ltt.polymtl.ca/svn@729 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/time.h | 12 ++++++--- .../poly/lttv/modules/gui/controlflow/cfv.c | 3 ++- .../poly/lttv/modules/gui/controlflow/cfv.h | 6 +++-- .../lttv/modules/gui/controlflow/drawing.c | 24 ++++++++--------- .../lttv/modules/gui/detailedevents/events.c | 16 ++++++------ .../gui/lttvwindow/lttvwindow/callbacks.c | 26 ++++++++----------- .../gui/lttvwindow/lttvwindow/lttvwindow.c | 12 ++++----- 7 files changed, 52 insertions(+), 47 deletions(-) diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index ec4d134b..642328e9 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -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); diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c index ece85cd3..01189e55 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c @@ -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 ; } diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h index 81f79a55..35119ab3 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 01d4260d..aaf8b030 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -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); } } diff --git a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c index 85f24148..f96d14a9 100644 --- a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c +++ b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c @@ -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; diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 2f42d263..e0e677fc 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -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; diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c index aa424772..e0700de2 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c @@ -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 } -- 2.34.1