]>
Commit | Line | Data |
---|---|---|
2a9a326b | 1 | /* Timing variables for measuring compiler performance. |
d652f226 | 2 | Copyright (C) 2000, 2003, 2004, 2005, 2007, 2009, 2010 |
7072a650 | 3 | Free Software Foundation, Inc. |
2a9a326b AS |
4 | Contributed by Alex Samuel <samuel@codesourcery.com> |
5 | ||
1322177d | 6 | This file is part of GCC. |
2a9a326b | 7 | |
1322177d LB |
8 | GCC is free software; you can redistribute it and/or modify it |
9 | under the terms of the GNU General Public License as published by | |
9dcd6f09 | 10 | the Free Software Foundation; either version 3, or (at your option) |
2a9a326b AS |
11 | any later version. |
12 | ||
1322177d LB |
13 | GCC is distributed in the hope that it will be useful, but WITHOUT |
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | |
16 | License for more details. | |
2a9a326b AS |
17 | |
18 | You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
19 | along with GCC; see the file COPYING3. If not see |
20 | <http://www.gnu.org/licenses/>. */ | |
2a9a326b | 21 | |
0e5921e8 ZW |
22 | #ifndef GCC_TIMEVAR_H |
23 | #define GCC_TIMEVAR_H | |
24 | ||
2a9a326b AS |
25 | /* Timing variables are used to measure elapsed time in various |
26 | portions of the compiler. Each measures elapsed user, system, and | |
27 | wall-clock time, as appropriate to and supported by the host | |
28 | system. | |
29 | ||
30 | Timing variables are defined using the DEFTIMEVAR macro in | |
31 | timevar.def. Each has an enumeral identifier, used when referring | |
32 | to the timing variable in code, and a character string name. | |
33 | ||
34 | Timing variables can be used in two ways: | |
35 | ||
36 | - On the timing stack, using timevar_push and timevar_pop. | |
37 | Timing variables may be pushed onto the stack; elapsed time is | |
38 | attributed to the topmost timing variable on the stack. When | |
39 | another variable is pushed on, the previous topmost variable is | |
40 | `paused' until the pushed variable is popped back off. | |
41 | ||
42 | - As a standalone timer, using timevar_start and timevar_stop. | |
43 | All time elapsed between the two calls is attributed to the | |
41077ce4 | 44 | variable. |
2a9a326b | 45 | */ |
41077ce4 | 46 | |
2a9a326b | 47 | /* This structure stores the various varieties of time that can be |
20cc76d5 | 48 | measured. Times are stored in seconds. The time may be an |
2a9a326b AS |
49 | absolute time or a time difference; in the former case, the time |
50 | base is undefined, except that the difference between two times | |
51 | produces a valid time difference. */ | |
52 | ||
53 | struct timevar_time_def | |
54 | { | |
55 | /* User time in this process. */ | |
4977bab6 | 56 | double user; |
2a9a326b AS |
57 | |
58 | /* System time (if applicable for this host platform) in this | |
59 | process. */ | |
4977bab6 | 60 | double sys; |
2a9a326b AS |
61 | |
62 | /* Wall clock time. */ | |
4977bab6 | 63 | double wall; |
8d18c628 ZD |
64 | |
65 | /* Garbage collector memory. */ | |
66 | unsigned ggc_mem; | |
2a9a326b AS |
67 | }; |
68 | ||
684d9f3b | 69 | /* An enumeration of timing variable identifiers. Constructed from |
2a9a326b AS |
70 | the contents of timevar.def. */ |
71 | ||
72 | #define DEFTIMEVAR(identifier__, name__) \ | |
41077ce4 | 73 | identifier__, |
2a9a326b AS |
74 | typedef enum |
75 | { | |
7072a650 | 76 | TV_NONE, |
2a9a326b AS |
77 | #include "timevar.def" |
78 | TIMEVAR_LAST | |
79 | } | |
80 | timevar_id_t; | |
81 | #undef DEFTIMEVAR | |
82 | ||
613b1547 SB |
83 | /* True if timevars should be used. In GCC, this happens with |
84 | the -ftime-report flag. */ | |
85 | extern bool timevar_enable; | |
86 | ||
87 | /* Total amount of memory allocated by garbage collector. */ | |
88 | extern size_t timevar_ggc_mem_total; | |
89 | ||
46c5ad27 | 90 | extern void timevar_init (void); |
89106ed5 AP |
91 | extern void timevar_push_1 (timevar_id_t); |
92 | extern void timevar_pop_1 (timevar_id_t); | |
46c5ad27 AJ |
93 | extern void timevar_start (timevar_id_t); |
94 | extern void timevar_stop (timevar_id_t); | |
575bfb00 LC |
95 | extern bool timevar_cond_start (timevar_id_t); |
96 | extern void timevar_cond_stop (timevar_id_t, bool); | |
46c5ad27 | 97 | extern void timevar_print (FILE *); |
2a9a326b AS |
98 | |
99 | /* Provided for backward compatibility. */ | |
613b1547 SB |
100 | static inline void |
101 | timevar_push (timevar_id_t tv) | |
102 | { | |
103 | if (timevar_enable) | |
104 | timevar_push_1 (tv); | |
105 | } | |
0e5921e8 | 106 | |
613b1547 SB |
107 | static inline void |
108 | timevar_pop (timevar_id_t tv) | |
109 | { | |
110 | if (timevar_enable) | |
111 | timevar_pop_1 (tv); | |
112 | } | |
89106ed5 | 113 | |
613b1547 | 114 | extern void print_time (const char *, long); |
8d18c628 | 115 | |
88657302 | 116 | #endif /* ! GCC_TIMEVAR_H */ |