[3745] | 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 | **************************************************************************/
|
---|
| 21 |
|
---|
| 22 | #ifndef H_TIMING
|
---|
| 23 | #define H_TIMING
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | #ifdef HAVE_TIMES
|
---|
| 27 | # if TIME_WITH_SYS_TIME
|
---|
| 28 | # include <sys/times.h>
|
---|
| 29 | # include <time.h>
|
---|
| 30 | # ifndef CLK_TCK
|
---|
| 31 | # define CLK_TCK sysconf(_SC_CLK_TCK)
|
---|
| 32 | # endif
|
---|
| 33 | # else
|
---|
| 34 | # if HAVE_SYS_TIME_H
|
---|
| 35 | # include <sys/time.h>
|
---|
| 36 | # else
|
---|
| 37 | # include <time.h>
|
---|
| 38 | # endif
|
---|
| 39 | # endif
|
---|
| 40 | #else
|
---|
| 41 | /* [RPAP - Feb 97: WIN32 Port] */
|
---|
| 42 | # ifdef __WIN32__
|
---|
| 43 | struct timeval { long tv_sec, tv_usec; };
|
---|
| 44 | # else
|
---|
| 45 | # include <sys/time.h>
|
---|
| 46 | # include <sys/resource.h>
|
---|
| 47 | # endif
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | typedef struct
|
---|
| 52 | {
|
---|
| 53 | double RealTime, CPUTime;
|
---|
| 54 | }
|
---|
| 55 | ProgTime;
|
---|
| 56 |
|
---|
| 57 | double RealTime (void);
|
---|
| 58 |
|
---|
| 59 | double CPUTime (double *user, double *sys);
|
---|
| 60 |
|
---|
| 61 | void GetTime (ProgTime * StartTime);
|
---|
| 62 |
|
---|
| 63 | /* FinishTime may be NULL */
|
---|
| 64 | char *ElapsedTime (ProgTime * StartTime, ProgTime * FinishTime);
|
---|
| 65 |
|
---|
| 66 | #ifdef HAVE_TIMES
|
---|
| 67 | char *cputime_string (clock_t clk);
|
---|
| 68 | #else
|
---|
| 69 | void time_normalise (struct timeval *t);
|
---|
| 70 | char *cputime_string (struct timeval *t);
|
---|
| 71 | #endif
|
---|
| 72 |
|
---|
| 73 | #endif
|
---|