1 #include <FCMangle.h> 2 #define TMRC FortranCInterface_GLOBAL_(tmrc, TMRC) 3 4 #include <stdio.h> 5 #include <sys/types.h> 6 #include <time.h> 7 8 #include <sys/time.h> 9 #include <sys/resource.h> 10 #include <unistd.h> 11 12 #ifdef __bgq__ 13 #include "hwi/include/bqc/A2_inlines.h" 14 #endif 15 TMRC(void)16double TMRC (void) 17 { 18 19 #ifdef __bgq__ 20 21 // use the GetTimeBase function available on BGQ 22 uint64_t TB = GetTimeBase(); 23 double t1 = 6.25e-10*TB; // = 1/1.6e9 24 25 #else 26 27 // use the gettimeofday function available on any Linux plateform 28 29 int rc; 30 struct timeval tv; 31 32 rc = gettimeofday (&tv, NULL); 33 if (rc == -1) { 34 fprintf(stderr,"tmrc: gettimeofday\n"); 35 return 0.; 36 } 37 double t1 = ((double) tv.tv_sec) + 1.e-6 * ((double) tv.tv_usec); 38 39 #endif 40 41 return t1; 42 43 44 // Old stuff 45 /* 46 struct rusage cputimePoints; 47 getrusage(RUSAGE_SELF,&cputimePoints); 48 double t1=((cputimePoints.ru_utime).tv_sec+(cputimePoints.ru_stime).tv_sec); 49 t1+=((cputimePoints.ru_utime).tv_usec+(cputimePoints.ru_stime).tv_usec)/1000000.0; 50 */ 51 52 /* double t1=rts_get_timebase()/( 2500000000.0); */ 53 54 /* return time(NULL); */ 55 /* return clock()/CLOCKS_PER_SEC; */ 56 } 57 58 59 60 61