1 | /**************************************************************************
|
---|
2 | *
|
---|
3 | * timing.h -- Program timing routines
|
---|
4 | * Copyright (C) 1994 Neil Sharman
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | *
|
---|
20 | * $Id: timing.h 439 1999-08-10 21:23:37Z sjboddie $
|
---|
21 | *
|
---|
22 | **************************************************************************/
|
---|
23 |
|
---|
24 | #ifndef H_TIMING
|
---|
25 | #define H_TIMING
|
---|
26 |
|
---|
27 |
|
---|
28 | #ifdef HAVE_TIMES
|
---|
29 | # if TIME_WITH_SYS_TIME
|
---|
30 | # include <sys/times.h>
|
---|
31 | # include <time.h>
|
---|
32 | # ifndef CLK_TCK
|
---|
33 | # define CLK_TCK sysconf(_SC_CLK_TCK)
|
---|
34 | # endif
|
---|
35 | # else
|
---|
36 | # if HAVE_SYS_TIME_H
|
---|
37 | # include <sys/time.h>
|
---|
38 | # else
|
---|
39 | # include <time.h>
|
---|
40 | # endif
|
---|
41 | # endif
|
---|
42 | #else
|
---|
43 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
44 | # ifdef __WIN32__
|
---|
45 | struct timeval { long tv_sec, tv_usec; };
|
---|
46 | # else
|
---|
47 | # include <sys/time.h>
|
---|
48 | # include <sys/resource.h>
|
---|
49 | # endif
|
---|
50 | #endif
|
---|
51 |
|
---|
52 |
|
---|
53 | typedef struct
|
---|
54 | {
|
---|
55 | double RealTime, CPUTime;
|
---|
56 | }
|
---|
57 | ProgTime;
|
---|
58 |
|
---|
59 | double RealTime (void);
|
---|
60 |
|
---|
61 | double CPUTime (double *user, double *sys);
|
---|
62 |
|
---|
63 | void GetTime (ProgTime * StartTime);
|
---|
64 |
|
---|
65 | /* FinishTime may be NULL */
|
---|
66 | char *ElapsedTime (ProgTime * StartTime, ProgTime * FinishTime);
|
---|
67 |
|
---|
68 | #ifdef HAVE_TIMES
|
---|
69 | char *cputime_string (clock_t clk);
|
---|
70 | #else
|
---|
71 | void time_normalise (struct timeval *t);
|
---|
72 | char *cputime_string (struct timeval *t);
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | #endif
|
---|