2 * Copyright (c) 1993 George V. Neville-Neil
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by George V. Neville-Neil
16 * 4. The name, George Neville-Neil may not be used to endorse or promote
17 * products derived from this software without specific prior
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #ifdef TIME_WITH_SYS_TIME
39 #else /* !TIME_WITH_SYS_TIME */
40 #ifdef HAVE_SYS_TIME_H
42 #else /* !HAVE_SYS_TIME_H */
44 #endif /* !HAVE_SYS_TIME_H */
45 #endif /* !TIME_WITH_SYS_TIME */
47 static struct timeval aftertp
, beforetp
;
49 #define BEGINTIMING gettimeofday(&beforetp, NULL)
51 #define ENDTIMING gettimeofday(&aftertp, NULL); \
52 if(beforetp.tv_usec > aftertp.tv_usec) \
54 aftertp.tv_usec += 1000000; \
58 #define TIMINGUS (((aftertp.tv_sec - beforetp.tv_sec) * 1000000) + \
59 (aftertp.tv_usec - beforetp.tv_usec))
61 #define TIMINGMS (((aftertp.tv_sec - beforetp.tv_sec) * 1000) + \
62 ((aftertp.tv_usec - beforetp.tv_usec) / 1000))
64 #define TIMINGS ((aftertp.tv_sec - beforetp.tv_sec) + \
65 (aftertp.tv_usec - beforetp.tv_usec) / 1000000)
67 #endif /* _TIMING_H_ */