Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Timer.c
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 #include "Timer.h"
20 #include <unistd.h>
21 
22 long long int Process_Sync_Offset = 0;
23 uint64_t Process_time_origin = 0;
25 
27 {
28  Process_time_origin = Timer_tsc();
29 }
30 
31 void Timer_set_offset(long long int offset )
32 {
33  Process_Sync_Offset = offset;
34 }
35 
36 
37 void Timer_Init_scale( unsigned int (*real_usleep)(unsigned int) )
38 {
39  double ret = 0;
40 
41  uint64_t begin = 0, end = 0;
42  double t_begin = 0, t_end = 0;
43 
44  struct timeval b_tv;
45  struct timeval e_tv;
46 
47  gettimeofday( &b_tv , NULL );
48  begin = Timer_tsc ();
49 
50  if( real_usleep )
51  (real_usleep)( 1 );
52 
53  end = Timer_tsc ();
54  gettimeofday( &e_tv , NULL );
55 
56  t_begin = b_tv.tv_sec + b_tv.tv_usec*1e-6;
57  t_end = e_tv.tv_sec + e_tv.tv_usec*1e-6;
58 
59  ret = (end-begin)/(t_end-t_begin);
60 
62 }
uint64_t Process_time_origin
The origin of the timer.
Definition: Timer.c:23
void Timer_Init_scale(unsigned int(*real_usleep)(unsigned int))
Timer_Init_scale.
Definition: Timer.c:37
long long int Process_Sync_Offset
The offset of the timer.
Definition: Timer.c:22
double Process_timer_second
A second in the timer scale.
Definition: Timer.c:24
void Timer_set_origin()
Initializes the timer (save current processor timer counter)
Definition: Timer.c:26
void Timer_set_offset(long long int offset)
Sets the offset to apply to timer.
Definition: Timer.c:31