Crossings Minimization  1.0
timing.c
Go to the documentation of this file.
1 /**
2  * @file timing.c
3  * @brief Implementation of a simple function to compute CPU milliseconds
4  * (user time only).
5  * @author Matt Stallmann
6  * @date ca. 1990
7  * $Id: timing.c 20 2011-06-26 23:29:46Z mfms $
8  */
9 
10 /* Propagate changes back to the C-Utilities repository. */
11 
12 #include "timing.h"
13 #include <sys/time.h>
14 #include <sys/resource.h>
15 
16 /** DEPRECATED -- see timing.h */
17 double currentCPUTime()
18 {
19  struct rusage ru;
20  getrusage(RUSAGE_SELF, &ru);
21 
22  return ( ru.ru_utime.tv_sec * 1000
23  + ru.ru_utime.tv_usec / 1000
24  );
25 }
26 
27 double getUserSeconds() {
28  struct rusage ru;
29  getrusage( RUSAGE_SELF, &ru );
30  return ( ru.ru_utime.tv_sec +
31  (double) ru.ru_utime.tv_usec / 1000000.0 );
32 }
33 
34 /* [Last modified: 2011 06 26 at 22:15:46 GMT] */
double currentCPUTime()
Definition: timing.c:17
double getUserSeconds()
Definition: timing.c:27
Header for a simple function to compute CPU user milliseconds.