From 90ef7e4a2c6a41ec36bd2530b187cc1ef2cf0025 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 12 Aug 2004 13:43:25 +0000 Subject: [PATCH] time operations optimisation git-svn-id: http://ltt.polymtl.ca/svn@710 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/time.h | 20 +++++++++++++++++++ .../poly/lttv/modules/gui/controlflow/cfv.c | 2 +- .../poly/lttv/modules/gui/controlflow/cfv.h | 2 +- .../lttv/modules/gui/controlflow/drawing.c | 20 +++++++++---------- .../lttv/modules/gui/controlflow/drawing.h | 4 ++-- .../lttv/modules/gui/controlflow/drawitem.c | 10 +++++----- .../lttv/modules/gui/controlflow/drawitem.h | 10 +++++----- .../lttv/modules/gui/controlflow/eventhooks.c | 7 ++++++- .../modules/gui/controlflow/processlist.c | 9 ++++----- .../modules/gui/controlflow/processlist.h | 4 ++-- .../gui/lttvwindow/lttvwindow/lttvwindow.c | 2 +- .../gui/lttvwindow/lttvwindow/lttvwindow.h | 2 +- 12 files changed, 58 insertions(+), 34 deletions(-) diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index a151505c..e350cc99 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c index fe0878be..ece85cd3 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c @@ -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 ; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h index 86a911c8..81f79a55 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index e84cdf5c..c504cf5b 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -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); } diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h index 30b70f1e..bac0b6b8 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h @@ -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, diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c index a73df51a..7284a2e8 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.c @@ -111,7 +111,7 @@ #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; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.h b/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.h index df945e3a..85fc837a 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawitem.h @@ -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 diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index c422e3e9..23bd9ff7 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -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 = diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c index df492e72..1cc7f139 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -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; diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h index 39b496d5..808e5fab 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h @@ -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, 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 ea848ada..51fb7b2d 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.c @@ -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; diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h index 25cb2a7f..18e5853e 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvwindow.h @@ -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); /** -- 2.34.1