Ice Sheet System Model  4.18
Code documentation
Functions
chaco_seconds.cpp File Reference
#include <sys/time.h>
#include <sys/resource.h>

Go to the source code of this file.

Functions

double chaco_seconds (void)
 

Function Documentation

◆ chaco_seconds()

double chaco_seconds ( void  )

Definition at line 10 of file chaco_seconds.cpp.

10  {
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 }