00001 char *cvsinfo_timing = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/timing.c,v 1.2 2013/04/28 07:58:43 tplarson Exp $"; 00002 00003 double getwalltime(void) 00004 { 00005 struct timeval tv; 00006 gettimeofday(&tv, NULL); 00007 return tv.tv_sec * 1000.0 + tv.tv_usec/1000.0; 00008 } 00009 00010 double getcputime(double *utime, double *stime) 00011 { 00012 00013 struct rusage ru; 00014 getrusage(RUSAGE_SELF, &ru); 00015 *utime = ru.ru_utime.tv_sec * 1000.0 + ru.ru_utime.tv_usec/1000.0; 00016 *stime = ru.ru_stime.tv_sec * 1000.0 + ru.ru_stime.tv_usec/1000.0; 00017 return *utime + *stime; 00018 }