]> git.saurik.com Git - bison.git/blob - lib/timevar.h
doc: merge HACKING and README-hacking.
[bison.git] / lib / timevar.h
1 /* Timing variables for measuring compiler performance.
2 Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
3 Contributed by Alex Samuel <samuel@codesourcery.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #ifndef GCC_TIMEVAR_H
19 #define GCC_TIMEVAR_H
20
21 /* Timing variables are used to measure elapsed time in various
22 portions of the compiler. Each measures elapsed user, system, and
23 wall-clock time, as appropriate to and supported by the host
24 system.
25
26 Timing variables are defined using the DEFTIMEVAR macro in
27 timevar.def. Each has an enumeral identifier, used when referring
28 to the timing variable in code, and a character string name.
29
30 Timing variables can be used in two ways:
31
32 - On the timing stack, using timevar_push and timevar_pop.
33 Timing variables may be pushed onto the stack; elapsed time is
34 attributed to the topmost timing variable on the stack. When
35 another variable is pushed on, the previous topmost variable is
36 `paused' until the pushed variable is popped back off.
37
38 - As a standalone timer, using timevar_start and timevar_stop.
39 All time elapsed between the two calls is attributed to the
40 variable.
41 */
42
43 /* This structure stores the various varieties of time that can be
44 measured. Times are stored in seconds. The time may be an
45 absolute time or a time difference; in the former case, the time
46 base is undefined, except that the difference between two times
47 produces a valid time difference. */
48
49 struct timevar_time_def
50 {
51 /* User time in this process. */
52 float user;
53
54 /* System time (if applicable for this host platform) in this
55 process. */
56 float sys;
57
58 /* Wall clock time. */
59 float wall;
60 };
61
62 /* An enumeration of timing variable identifiers. Constructed from
63 the contents of timevar.def. */
64
65 #define DEFTIMEVAR(identifier__, name__) \
66 identifier__,
67 typedef enum
68 {
69 #include "timevar.def"
70 TIMEVAR_LAST
71 }
72 timevar_id_t;
73 #undef DEFTIMEVAR
74
75 extern void init_timevar (void);
76 extern void timevar_push (timevar_id_t);
77 extern void timevar_pop (timevar_id_t);
78 extern void timevar_start (timevar_id_t);
79 extern void timevar_stop (timevar_id_t);
80 extern void timevar_get (timevar_id_t, struct timevar_time_def *);
81 extern void timevar_print (FILE *);
82
83 /* Provided for backward compatibility. */
84 extern long get_run_time (void);
85 extern void print_time (const char *, long);
86
87 extern int timevar_report;
88
89 #endif /* ! GCC_TIMEVAR_H */