21 #include "my_global.h"
31 static ulonglong cycle_v0;
32 static ulonglong nanosec_v0;
33 static ulonglong microsec_v0;
34 static ulonglong millisec_v0;
35 static ulonglong tick_v0;
37 static ulong cycle_to_pico;
38 static ulong nanosec_to_pico;
39 static ulong microsec_to_pico;
40 static ulong millisec_to_pico;
41 static ulonglong tick_to_pico;
54 static inline ulong round_to_ulong(
double value)
56 return (ulong) (value + 0.5);
59 static inline ulonglong round_to_ulonglong(
double value)
61 return (ulonglong) (value + 0.5);
66 double pico_frequency= 1.0e12;
68 my_timer_init(&pfs_timer_info);
70 cycle_v0= my_timer_cycles();
71 nanosec_v0= my_timer_nanoseconds();
72 microsec_v0= my_timer_microseconds();
73 millisec_v0= my_timer_milliseconds();
74 tick_v0= my_timer_ticks();
77 cycle_to_pico= round_to_ulong(pico_frequency/
83 nanosec_to_pico= round_to_ulong(pico_frequency/
89 microsec_to_pico= round_to_ulong(pico_frequency/
95 millisec_to_pico= round_to_ulong(pico_frequency/
101 tick_to_pico= round_to_ulonglong(pico_frequency/
106 to_pico_data[TIMER_NAME_CYCLE].
m_v0= cycle_v0;
107 to_pico_data[TIMER_NAME_CYCLE].
m_factor= cycle_to_pico;
109 to_pico_data[TIMER_NAME_NANOSEC].
m_v0= nanosec_v0;
110 to_pico_data[TIMER_NAME_NANOSEC].
m_factor= nanosec_to_pico;
112 to_pico_data[TIMER_NAME_MICROSEC].
m_v0= microsec_v0;
113 to_pico_data[TIMER_NAME_MICROSEC].
m_factor= microsec_to_pico;
115 to_pico_data[TIMER_NAME_MILLISEC].
m_v0= millisec_v0;
116 to_pico_data[TIMER_NAME_MILLISEC].
m_factor= millisec_to_pico;
118 to_pico_data[TIMER_NAME_TICK].
m_v0= tick_v0;
119 to_pico_data[TIMER_NAME_TICK].
m_factor= tick_to_pico;
132 if (nanosec_to_pico != 0)
138 else if (microsec_to_pico != 0)
144 else if (millisec_to_pico != 0)
150 else if (tick_to_pico != 0)
169 if (microsec_to_pico != 0)
174 else if (millisec_to_pico != 0)
179 else if (tick_to_pico != 0)
195 case TIMER_NAME_CYCLE:
196 return my_timer_cycles();
197 case TIMER_NAME_NANOSEC:
198 return my_timer_nanoseconds();
199 case TIMER_NAME_MICROSEC:
200 return my_timer_microseconds();
201 case TIMER_NAME_MILLISEC:
202 return my_timer_milliseconds();
203 case TIMER_NAME_TICK:
204 return my_timer_ticks();
215 case TIMER_NAME_CYCLE:
216 *fct= my_timer_cycles;
217 return my_timer_cycles();
218 case TIMER_NAME_NANOSEC:
219 *fct= my_timer_nanoseconds;
220 return my_timer_nanoseconds();
221 case TIMER_NAME_MICROSEC:
222 *fct= my_timer_microseconds;
223 return my_timer_microseconds();
224 case TIMER_NAME_MILLISEC:
225 *fct= my_timer_milliseconds;
226 return my_timer_milliseconds();
227 case TIMER_NAME_TICK:
228 *fct= my_timer_ticks;
229 return my_timer_ticks();
243 case TIMER_NAME_CYCLE:
244 result= (my_timer_cycles() - cycle_v0) * cycle_to_pico;
246 case TIMER_NAME_NANOSEC:
247 result= (my_timer_nanoseconds() - nanosec_v0) * nanosec_to_pico;
249 case TIMER_NAME_MICROSEC:
250 result= (my_timer_microseconds() - microsec_v0) * microsec_to_pico;
252 case TIMER_NAME_MILLISEC:
253 result= (my_timer_milliseconds() - millisec_v0) * millisec_to_pico;
255 case TIMER_NAME_TICK:
256 result= (my_timer_ticks() - tick_v0) * tick_to_pico;
267 uint
index=
static_cast<uint
> (timer_name);
272 return & to_pico_data[
index];
276 ulonglong *pico_start, ulonglong *pico_end, ulonglong *pico_wait)
295 *pico_wait= (end - start) *
m_factor;