1 |
207 |
jeremybenn |
/* High precision, low overhead timing functions. Generic version.
|
2 |
|
|
Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
3 |
|
|
This file is part of the GNU C Library.
|
4 |
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
|
5 |
|
|
|
6 |
|
|
The GNU C Library is free software; you can redistribute it and/or
|
7 |
|
|
modify it under the terms of the GNU Lesser General Public
|
8 |
|
|
License as published by the Free Software Foundation; either
|
9 |
|
|
version 2.1 of the License, or (at your option) any later version.
|
10 |
|
|
|
11 |
|
|
The GNU C Library 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 GNU
|
14 |
|
|
Lesser General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU Lesser General Public
|
17 |
|
|
License along with the GNU C Library; if not, write to the Free
|
18 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
19 |
|
|
02111-1307 USA. */
|
20 |
|
|
|
21 |
|
|
#ifndef _HP_TIMING_H
|
22 |
|
|
#define _HP_TIMING_H 1
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/* There are no generic definitions for the times. We could write something
|
26 |
|
|
using the `gettimeofday' system call where available but the overhead of
|
27 |
|
|
the system call might be too high.
|
28 |
|
|
|
29 |
|
|
In case a platform supports timers in the hardware the following macros
|
30 |
|
|
and types must be defined:
|
31 |
|
|
|
32 |
|
|
- HP_TIMING_AVAIL: test for availability.
|
33 |
|
|
|
34 |
|
|
- HP_TIMING_INLINE: this macro is non-zero if the functionality is not
|
35 |
|
|
implemented using function calls but instead uses some inlined code
|
36 |
|
|
which might simply consist of a few assembler instructions. We have to
|
37 |
|
|
know this since we might want to use the macros here in places where we
|
38 |
|
|
cannot make function calls.
|
39 |
|
|
|
40 |
|
|
- hp_timing_t: This is the type for variables used to store the time
|
41 |
|
|
values.
|
42 |
|
|
|
43 |
|
|
- HP_TIMING_ZERO: clear `hp_timing_t' object.
|
44 |
|
|
|
45 |
|
|
- HP_TIMING_NOW: place timestamp for current time in variable given as
|
46 |
|
|
parameter.
|
47 |
|
|
|
48 |
|
|
- HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the
|
49 |
|
|
HP_TIMING_DIFF macro.
|
50 |
|
|
|
51 |
|
|
- HP_TIMING_DIFF: compute difference between two times and store it
|
52 |
|
|
in a third. Source and destination might overlap.
|
53 |
|
|
|
54 |
|
|
- HP_TIMING_ACCUM: add time difference to another variable. This might
|
55 |
|
|
be a bit more complicated to implement for some platforms as the
|
56 |
|
|
operation should be thread-safe and 64bit arithmetic on 32bit platforms
|
57 |
|
|
is not.
|
58 |
|
|
|
59 |
|
|
- HP_TIMING_ACCUM_NT: this is the variant for situations where we know
|
60 |
|
|
there are no threads involved.
|
61 |
|
|
|
62 |
|
|
- HP_TIMING_PRINT: write decimal representation of the timing value into
|
63 |
|
|
the given string. This operation need not be inline even though
|
64 |
|
|
HP_TIMING_INLINE is specified.
|
65 |
|
|
|
66 |
|
|
*/
|
67 |
|
|
|
68 |
|
|
/* Provide dummy definitions. */
|
69 |
|
|
#define HP_TIMING_AVAIL (0)
|
70 |
|
|
#define HP_TIMING_INLINE (0)
|
71 |
|
|
typedef int hp_timing_t;
|
72 |
|
|
#define HP_TIMING_ZERO(Var)
|
73 |
|
|
#define HP_TIMING_NOW(var)
|
74 |
|
|
#define HP_TIMING_DIFF_INIT()
|
75 |
|
|
#define HP_TIMING_DIFF(Diff, Start, End)
|
76 |
|
|
#define HP_TIMING_ACCUM(Sum, Diff)
|
77 |
|
|
#define HP_TIMING_ACCUM_NT(Sum, Diff)
|
78 |
|
|
#define HP_TIMING_PRINT(Buf, Len, Val)
|
79 |
|
|
|
80 |
|
|
/* Since this implementation is not available we tell the user about it. */
|
81 |
|
|
#define HP_TIMING_NONAVAIL 1
|
82 |
|
|
|
83 |
|
|
#endif /* hp-timing.h */
|