00001 char *cvsinfo_timing = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/mag/synop/apps/synop-timing.c,v 1.1 2016/05/05 19:49:28 arta Exp $"; 00002 00003 #include <stdio.h> 00004 #include <math.h> 00005 #include <stdlib.h> 00006 #include <time.h> 00007 #include <sys/time.h> 00008 #include <sys/resource.h> 00009 #include "jsoc_main.h" 00010 00011 double getwalltime(void) 00012 { 00013 struct timeval tv; 00014 gettimeofday(&tv, NULL); 00015 return tv.tv_sec * 1000.0 + tv.tv_usec/1000.0; 00016 } 00017 00018 double getcputime(double *utime, double *stime) 00019 { 00020 00021 struct rusage ru; 00022 getrusage(RUSAGE_SELF, &ru); 00023 *utime = ru.ru_utime.tv_sec * 1000.0 + ru.ru_utime.tv_usec/1000.0; 00024 *stime = ru.ru_stime.tv_sec * 1000.0 + ru.ru_stime.tv_usec/1000.0; 00025 return *utime + *stime; 00026 }