floor, ceil, trunc, truncf, truncl: Defeat GCC optimizations.
[gnulib.git] / lib / timevar.h
blobff443fed6ba684e477b3fdcd34f3056c4fa80e97
1 /* Timing variables for measuring application performance.
3 Copyright (C) 2000, 2002, 2004, 2009-2015, 2018 Free Software
4 Foundation, Inc.
6 Contributed by Alex Samuel <samuel@codesourcery.com>
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #ifndef _TIMEVAR_H
22 # define _TIMEVAR_H 1
24 # include <stdio.h>
26 # ifdef __cplusplus
27 extern "C" {
28 # endif
30 /* Timing variables are used to measure elapsed time in various
31 portions of the application. Each measures elapsed user, system, and
32 wall-clock time, as appropriate to and supported by the host
33 system.
35 Timing variables are defined using the DEFTIMEVAR macro in
36 timevar.def. Each has an enumeral identifier, used when referring
37 to the timing variable in code, and a character string name.
39 Timing variables can be used in two ways:
41 - On the timing stack, using timevar_push and timevar_pop.
42 Timing variables may be pushed onto the stack; elapsed time is
43 attributed to the topmost timing variable on the stack. When
44 another variable is pushed on, the previous topmost variable is
45 'paused' until the pushed variable is popped back off.
47 - As a standalone timer, using timevar_start and timevar_stop.
48 All time elapsed between the two calls is attributed to the
49 variable.
52 /* This structure stores the various varieties of time that can be
53 measured. Times are stored in seconds. The time may be an
54 absolute time or a time difference; in the former case, the time
55 base is undefined, except that the difference between two times
56 produces a valid time difference. */
58 struct timevar_time_def
60 /* User time in this process. */
61 float user;
63 /* System time (if applicable for this host platform) in this
64 process. */
65 float sys;
67 /* Wall clock time. */
68 float wall;
71 /* An enumeration of timing variable identifiers. Constructed from
72 the contents of timevar.def. */
74 #define DEFTIMEVAR(identifier__, name__) \
75 identifier__,
76 typedef enum
78 #include "timevar.def"
79 TIMEVAR_LAST
81 timevar_id_t;
82 #undef DEFTIMEVAR
84 /* Initialize timing variables. */
86 void timevar_init (void);
88 /* Push TIMEVAR onto the timing stack. No further elapsed time is
89 attributed to the previous topmost timing variable on the stack;
90 subsequent elapsed time is attributed to TIMEVAR, until it is
91 popped or another element is pushed on top.
93 TIMEVAR cannot be running as a standalone timer. */
95 void timevar_push (timevar_id_t timevar);
97 /* Pop the topmost timing variable element off the timing stack. The
98 popped variable must be TIMEVAR. Elapsed time since the that
99 element was pushed on, or since it was last exposed on top of the
100 stack when the element above it was popped off, is credited to that
101 timing variable. */
103 void timevar_pop (timevar_id_t timevar);
105 /* Start timing TIMEVAR independently of the timing stack. Elapsed
106 time until timevar_stop is called for the same timing variable is
107 attributed to TIMEVAR. */
109 void timevar_start (timevar_id_t timevar);
111 /* Stop timing TIMEVAR. Time elapsed since timevar_start was called
112 is attributed to it. */
114 void timevar_stop (timevar_id_t timevar);
116 /* Fill the elapsed time for TIMEVAR into ELAPSED. Returns
117 update-to-date information even if TIMEVAR is currently running. */
119 void timevar_get (timevar_id_t timevar, struct timevar_time_def *elapsed);
121 /* Summarize timing variables to FP. The timing variable TV_TOTAL has
122 a special meaning -- it's considered to be the total elapsed time,
123 for normalizing the others, and is displayed last. */
125 void timevar_print (FILE *fp);
127 /* Set to to nonzero to enable timing variables. All the timevar
128 functions make an early exit if timevar is disabled. */
130 extern int timevar_enabled;
132 # ifdef __cplusplus
134 # endif
136 #endif /* ! _TIMEVAR_H */