PIPS
pyps_gettime.c
Go to the documentation of this file.
1 #ifndef PYPS_TIME_FILE
2  #error pyps should define PYPS_TIME_FILE on its own
3 #endif
4 #include <sys/time.h>
5 #include <stdio.h>
6 
7 // Warning: these functions aren't thread-safe !!
8 
9 static FILE *__pyps_timefile = 0;
10 
11 void __pyps_bench_start(struct timeval *timestart)
12 {
13  gettimeofday(timestart, NULL);
14 }
15 
16 void __pyps_bench_stop(const char* module, const struct timeval *timestart)
17 {
18  struct timeval timeend;
19  gettimeofday(&timeend, NULL);
20 
21  long diff = (timeend.tv_sec-timestart->tv_sec)*1000000 + (timeend.tv_usec-timestart->tv_usec);
22 
23  if (__pyps_timefile == 0)
24  __pyps_timefile = fopen(PYPS_TIME_FILE, "w");
25  if (__pyps_timefile)
26  {
27  fprintf(__pyps_timefile, "%s: %ld\n", module, diff);
28  fflush(__pyps_timefile);
29  }
30 }
31 
33 {
34  if (__pyps_timefile != 0)
35  fclose(__pyps_timefile);
36 }
static char * module
Definition: pips.c:74
void __pyps_bench_start(struct timeval *timestart)
Definition: pyps_gettime.c:11
atexit(__pyps_bench_close)
void __pyps_bench_close(void)
Definition: pyps_gettime.c:32
static FILE * __pyps_timefile
Definition: pyps_gettime.c:9
void __pyps_bench_stop(const char *module, const struct timeval *timestart)
Definition: pyps_gettime.c:16
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...