Ice Sheet System Model  4.18
Code documentation
chaco_seconds.cpp
Go to the documentation of this file.
1 /*This is needed, because the chaco library defines a "C" function seconds that conflicts with the Metis version.: */
2 
3 #ifdef _INTEL_WIN_
4 #include <time.h>
5 #else
6 #include <sys/time.h>
7 #include <sys/resource.h>
8 #endif
9 
10 double chaco_seconds(void){
11 
12  double curtime;
13 
14 #ifdef RUSAGE_SELF
15 
16 /* This timer is faster and more robust (if it exists). */
17  struct rusage rusage;
18  /*int getrusage(); commenting this out. not sure why it's there anymore
19  *as it clobbers the prototype int getrusag(int target,rusage* results) which
20  *is defined in the <sys/time.h> and <sys/resource.h> header files. Leaving it
21  *for reference in case we have a problem here in the future*/
22 
23  getrusage(RUSAGE_SELF, &rusage);
24  curtime = ((rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec) +
25  1.0e-6 * (rusage.ru_utime.tv_usec + rusage.ru_stime.tv_usec));
26 
27 #else
28 
29 /* ANSI timer, but lower resolution & wraps around after ~36 minutes. */
30 
31  curtime = clock()/((double) CLOCKS_PER_SEC);
32 
33 #endif
34 
35  return (curtime);
36 }
chaco_seconds
double chaco_seconds(void)
Definition: chaco_seconds.cpp:10