1 /* Tracking cpu/system/elapsed time used by a process.
2  *
3  * SRE, Wed Feb 22 19:30:36 2006 [St. Louis] [moved to Easel]
4  * SRE, Thu Aug  3 08:00:35 2000 [St. Louis] [moved to SQUID]
5  * SRE, Fri Nov 26 14:54:21 1999 [St. Louis] [HMMER]
6  */
7 #ifndef eslSTOPWATCH_INCLUDED
8 #define eslSTOPWATCH_INCLUDED
9 #include "esl_config.h"
10 
11 #include <time.h>
12 #ifdef HAVE_TIMES
13 #include <sys/times.h>
14 #endif
15 #ifdef HAVE_UNISTD_H
16 #include <unistd.h>		/* need for sysconf() */
17 #endif
18 
19 typedef struct {
20 #ifdef eslSTOPWATCH_HIGHRES
21   double     t0;                /* baseline wall time from Nadeau routine */
22 #elif  HAVE_TIMES
23   clock_t    t0;		/* baseline wall time, POSIX times()      */
24 #else
25   time_t     t0;                /* baseline wall time from ANSI time()    */
26 #endif
27 
28 #ifdef HAVE_TIMES
29   struct tms cpu0;		/* baseline CPU/system time, POSIX times()      */
30 #else
31   clock_t cpu0;			/* baseline CPU time, fallback to ANSI clock()  */
32 #endif
33 
34   /* elapsed/user/sys are t-t0 results for the last time the
35    * watch was Stop()'ed.
36    */
37   double elapsed;               /* elapsed wall time, seconds */
38   double user;                  /* CPU time, seconds          */
39   double sys;                   /* system time, seconds       */
40 } ESL_STOPWATCH;
41 
42 
43 extern ESL_STOPWATCH *esl_stopwatch_Create(void);
44 extern void           esl_stopwatch_Destroy(ESL_STOPWATCH *w);
45 
46 extern int esl_stopwatch_Start(ESL_STOPWATCH *w);
47 extern int esl_stopwatch_Stop(ESL_STOPWATCH *w);
48 extern int esl_stopwatch_Display(FILE *fp, ESL_STOPWATCH *w, char *prefix);
49 
50 extern double esl_stopwatch_GetElapsed(ESL_STOPWATCH *w);
51 
52 extern int esl_stopwatch_Include(ESL_STOPWATCH *master, ESL_STOPWATCH *w);
53 
54 
55 #endif /*eslSTOPWATCH_INCLUDED*/
56 
57 
58