annotate gcc/timevar.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Timing variables for measuring compiler performance.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Alex Samuel <samuel@codesourcery.com>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #ifndef GCC_TIMEVAR_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define GCC_TIMEVAR_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 /* Timing variables are used to measure elapsed time in various
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 portions of the compiler. Each measures elapsed user, system, and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 wall-clock time, as appropriate to and supported by the host
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 system.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 Timing variables are defined using the DEFTIMEVAR macro in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 timevar.def. Each has an enumeral identifier, used when referring
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 to the timing variable in code, and a character string name.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 Timing variables can be used in two ways:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 - On the timing stack, using timevar_push and timevar_pop.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 Timing variables may be pushed onto the stack; elapsed time is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 attributed to the topmost timing variable on the stack. When
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 another variable is pushed on, the previous topmost variable is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 `paused' until the pushed variable is popped back off.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 - As a standalone timer, using timevar_start and timevar_stop.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 All time elapsed between the two calls is attributed to the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 variable.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 /* This structure stores the various varieties of time that can be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 measured. Times are stored in seconds. The time may be an
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 absolute time or a time difference; in the former case, the time
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 base is undefined, except that the difference between two times
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 produces a valid time difference. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 struct timevar_time_def
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 /* User time in this process. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 double user;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 /* System time (if applicable for this host platform) in this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 process. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 double sys;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 /* Wall clock time. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 double wall;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 /* Garbage collector memory. */
111
kono
parents: 67
diff changeset
65 size_t ggc_mem;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 /* An enumeration of timing variable identifiers. Constructed from
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 the contents of timevar.def. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 #define DEFTIMEVAR(identifier__, name__) \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 identifier__,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 typedef enum
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 {
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
75 TV_NONE,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 #include "timevar.def"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 TIMEVAR_LAST
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 timevar_id_t;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 #undef DEFTIMEVAR
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
111
kono
parents: 67
diff changeset
82 /* A class to hold all state relating to timing. */
kono
parents: 67
diff changeset
83
kono
parents: 67
diff changeset
84 class timer;
kono
parents: 67
diff changeset
85
kono
parents: 67
diff changeset
86 /* The singleton instance of timing state.
kono
parents: 67
diff changeset
87
kono
parents: 67
diff changeset
88 This is non-NULL if timevars should be used. In GCC, this happens with
kono
parents: 67
diff changeset
89 the -ftime-report flag. Hence this is NULL for the common,
kono
parents: 67
diff changeset
90 needs-to-be-fast case, with an early reject happening for this being
kono
parents: 67
diff changeset
91 NULL. */
kono
parents: 67
diff changeset
92 extern timer *g_timer;
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
93
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
94 /* Total amount of memory allocated by garbage collector. */
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
95 extern size_t timevar_ggc_mem_total;
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
96
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 extern void timevar_init (void);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 extern void timevar_start (timevar_id_t);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 extern void timevar_stop (timevar_id_t);
111
kono
parents: 67
diff changeset
100 extern bool timevar_cond_start (timevar_id_t);
kono
parents: 67
diff changeset
101 extern void timevar_cond_stop (timevar_id_t, bool);
kono
parents: 67
diff changeset
102
kono
parents: 67
diff changeset
103 /* The public (within GCC) interface for timing. */
kono
parents: 67
diff changeset
104
kono
parents: 67
diff changeset
105 class timer
kono
parents: 67
diff changeset
106 {
kono
parents: 67
diff changeset
107 public:
kono
parents: 67
diff changeset
108 timer ();
kono
parents: 67
diff changeset
109 ~timer ();
kono
parents: 67
diff changeset
110
kono
parents: 67
diff changeset
111 void start (timevar_id_t tv);
kono
parents: 67
diff changeset
112 void stop (timevar_id_t tv);
kono
parents: 67
diff changeset
113 void push (timevar_id_t tv);
kono
parents: 67
diff changeset
114 void pop (timevar_id_t tv);
kono
parents: 67
diff changeset
115 bool cond_start (timevar_id_t tv);
kono
parents: 67
diff changeset
116 void cond_stop (timevar_id_t tv);
kono
parents: 67
diff changeset
117
kono
parents: 67
diff changeset
118 void push_client_item (const char *item_name);
kono
parents: 67
diff changeset
119 void pop_client_item ();
kono
parents: 67
diff changeset
120
kono
parents: 67
diff changeset
121 void print (FILE *fp);
kono
parents: 67
diff changeset
122
kono
parents: 67
diff changeset
123 const char *get_topmost_item_name () const;
kono
parents: 67
diff changeset
124
kono
parents: 67
diff changeset
125 private:
kono
parents: 67
diff changeset
126 /* Private member functions. */
kono
parents: 67
diff changeset
127 void validate_phases (FILE *fp) const;
kono
parents: 67
diff changeset
128
kono
parents: 67
diff changeset
129 struct timevar_def;
kono
parents: 67
diff changeset
130 void push_internal (struct timevar_def *tv);
kono
parents: 67
diff changeset
131 void pop_internal ();
kono
parents: 67
diff changeset
132 static void print_row (FILE *fp,
kono
parents: 67
diff changeset
133 const timevar_time_def *total,
kono
parents: 67
diff changeset
134 const char *name, const timevar_time_def &elapsed);
kono
parents: 67
diff changeset
135 static bool all_zero (const timevar_time_def &elapsed);
kono
parents: 67
diff changeset
136
kono
parents: 67
diff changeset
137 private:
kono
parents: 67
diff changeset
138 typedef hash_map<timevar_def *, timevar_time_def> child_map_t;
kono
parents: 67
diff changeset
139
kono
parents: 67
diff changeset
140 /* Private type: a timing variable. */
kono
parents: 67
diff changeset
141 struct timevar_def
kono
parents: 67
diff changeset
142 {
kono
parents: 67
diff changeset
143 /* Elapsed time for this variable. */
kono
parents: 67
diff changeset
144 struct timevar_time_def elapsed;
kono
parents: 67
diff changeset
145
kono
parents: 67
diff changeset
146 /* If this variable is timed independently of the timing stack,
kono
parents: 67
diff changeset
147 using timevar_start, this contains the start time. */
kono
parents: 67
diff changeset
148 struct timevar_time_def start_time;
kono
parents: 67
diff changeset
149
kono
parents: 67
diff changeset
150 /* The name of this timing variable. */
kono
parents: 67
diff changeset
151 const char *name;
kono
parents: 67
diff changeset
152
kono
parents: 67
diff changeset
153 /* Nonzero if this timing variable is running as a standalone
kono
parents: 67
diff changeset
154 timer. */
kono
parents: 67
diff changeset
155 unsigned standalone : 1;
kono
parents: 67
diff changeset
156
kono
parents: 67
diff changeset
157 /* Nonzero if this timing variable was ever started or pushed onto
kono
parents: 67
diff changeset
158 the timing stack. */
kono
parents: 67
diff changeset
159 unsigned used : 1;
kono
parents: 67
diff changeset
160
kono
parents: 67
diff changeset
161 child_map_t *children;
kono
parents: 67
diff changeset
162 };
kono
parents: 67
diff changeset
163
kono
parents: 67
diff changeset
164 /* Private type: an element on the timing stack
kono
parents: 67
diff changeset
165 Elapsed time is attributed to the topmost timing variable on the
kono
parents: 67
diff changeset
166 stack. */
kono
parents: 67
diff changeset
167 struct timevar_stack_def
kono
parents: 67
diff changeset
168 {
kono
parents: 67
diff changeset
169 /* The timing variable at this stack level. */
kono
parents: 67
diff changeset
170 struct timevar_def *timevar;
kono
parents: 67
diff changeset
171
kono
parents: 67
diff changeset
172 /* The next lower timing variable context in the stack. */
kono
parents: 67
diff changeset
173 struct timevar_stack_def *next;
kono
parents: 67
diff changeset
174 };
kono
parents: 67
diff changeset
175
kono
parents: 67
diff changeset
176 /* A class for managing a collection of named timing items, for use
kono
parents: 67
diff changeset
177 e.g. by libgccjit for timing client code. This class is declared
kono
parents: 67
diff changeset
178 inside timevar.c to avoid everything using timevar.h
kono
parents: 67
diff changeset
179 from needing vec and hash_map. */
kono
parents: 67
diff changeset
180 class named_items;
kono
parents: 67
diff changeset
181
kono
parents: 67
diff changeset
182 private:
kono
parents: 67
diff changeset
183
kono
parents: 67
diff changeset
184 /* Data members (all private). */
kono
parents: 67
diff changeset
185
kono
parents: 67
diff changeset
186 /* Declared timing variables. Constructed from the contents of
kono
parents: 67
diff changeset
187 timevar.def. */
kono
parents: 67
diff changeset
188 timevar_def m_timevars[TIMEVAR_LAST];
kono
parents: 67
diff changeset
189
kono
parents: 67
diff changeset
190 /* The top of the timing stack. */
kono
parents: 67
diff changeset
191 timevar_stack_def *m_stack;
kono
parents: 67
diff changeset
192
kono
parents: 67
diff changeset
193 /* A list of unused (i.e. allocated and subsequently popped)
kono
parents: 67
diff changeset
194 timevar_stack_def instances. */
kono
parents: 67
diff changeset
195 timevar_stack_def *m_unused_stack_instances;
kono
parents: 67
diff changeset
196
kono
parents: 67
diff changeset
197 /* The time at which the topmost element on the timing stack was
kono
parents: 67
diff changeset
198 pushed. Time elapsed since then is attributed to the topmost
kono
parents: 67
diff changeset
199 element. */
kono
parents: 67
diff changeset
200 timevar_time_def m_start_time;
kono
parents: 67
diff changeset
201
kono
parents: 67
diff changeset
202 /* If non-NULL, for use when timing libgccjit's client code. */
kono
parents: 67
diff changeset
203 named_items *m_jit_client_items;
kono
parents: 67
diff changeset
204
kono
parents: 67
diff changeset
205 friend class named_items;
kono
parents: 67
diff changeset
206 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 /* Provided for backward compatibility. */
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
209 static inline void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
210 timevar_push (timevar_id_t tv)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
211 {
111
kono
parents: 67
diff changeset
212 if (g_timer)
kono
parents: 67
diff changeset
213 g_timer->push (tv);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
214 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
215
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
216 static inline void
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
217 timevar_pop (timevar_id_t tv)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
218 {
111
kono
parents: 67
diff changeset
219 if (g_timer)
kono
parents: 67
diff changeset
220 g_timer->pop (tv);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
221 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
222
111
kono
parents: 67
diff changeset
223 // This is a simple timevar wrapper class that pushes a timevar in its
kono
parents: 67
diff changeset
224 // constructor and pops the timevar in its destructor.
kono
parents: 67
diff changeset
225 class auto_timevar
kono
parents: 67
diff changeset
226 {
kono
parents: 67
diff changeset
227 public:
kono
parents: 67
diff changeset
228 auto_timevar (timer *t, timevar_id_t tv)
kono
parents: 67
diff changeset
229 : m_timer (t),
kono
parents: 67
diff changeset
230 m_tv (tv)
kono
parents: 67
diff changeset
231 {
kono
parents: 67
diff changeset
232 if (m_timer)
kono
parents: 67
diff changeset
233 m_timer->push (m_tv);
kono
parents: 67
diff changeset
234 }
kono
parents: 67
diff changeset
235
kono
parents: 67
diff changeset
236 explicit auto_timevar (timevar_id_t tv)
kono
parents: 67
diff changeset
237 : m_timer (g_timer)
kono
parents: 67
diff changeset
238 , m_tv (tv)
kono
parents: 67
diff changeset
239 {
kono
parents: 67
diff changeset
240 if (m_timer)
kono
parents: 67
diff changeset
241 m_timer->push (m_tv);
kono
parents: 67
diff changeset
242 }
kono
parents: 67
diff changeset
243
kono
parents: 67
diff changeset
244 ~auto_timevar ()
kono
parents: 67
diff changeset
245 {
kono
parents: 67
diff changeset
246 if (m_timer)
kono
parents: 67
diff changeset
247 m_timer->pop (m_tv);
kono
parents: 67
diff changeset
248 }
kono
parents: 67
diff changeset
249
kono
parents: 67
diff changeset
250 private:
kono
parents: 67
diff changeset
251
kono
parents: 67
diff changeset
252 // Private to disallow copies.
kono
parents: 67
diff changeset
253 auto_timevar (const auto_timevar &);
kono
parents: 67
diff changeset
254
kono
parents: 67
diff changeset
255 timer *m_timer;
kono
parents: 67
diff changeset
256 timevar_id_t m_tv;
kono
parents: 67
diff changeset
257 };
kono
parents: 67
diff changeset
258
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 extern void print_time (const char *, long);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 #endif /* ! GCC_TIMEVAR_H */