Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: tools/gn/trace.cc

Issue 2424233002: [gn] Add trace entries for loading and blocking on imports (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/trace.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/trace.h" 5 #include "tools/gn/trace.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 AddTrace(item_); 163 AddTrace(item_);
164 } 164 }
165 } 165 }
166 } 166 }
167 167
168 void EnableTracing() { 168 void EnableTracing() {
169 if (!trace_log) 169 if (!trace_log)
170 trace_log = new TraceLog; 170 trace_log = new TraceLog;
171 } 171 }
172 172
173 bool TracingEnabled() {
174 return !!trace_log;
175 }
176
173 void AddTrace(TraceItem* item) { 177 void AddTrace(TraceItem* item) {
174 trace_log->Add(item); 178 trace_log->Add(item);
175 } 179 }
176 180
177 std::string SummarizeTraces() { 181 std::string SummarizeTraces() {
178 if (!trace_log) 182 if (!trace_log)
179 return std::string(); 183 return std::string();
180 184
181 std::vector<TraceItem*> events = trace_log->events(); 185 std::vector<TraceItem*> events = trace_log->events();
182 186
(...skipping 13 matching lines...) Expand all
196 break; 200 break;
197 case TraceItem::TRACE_SCRIPT_EXECUTE: 201 case TraceItem::TRACE_SCRIPT_EXECUTE:
198 script_execs.push_back(event); 202 script_execs.push_back(event);
199 break; 203 break;
200 case TraceItem::TRACE_CHECK_HEADERS: 204 case TraceItem::TRACE_CHECK_HEADERS:
201 check_headers.push_back(event); 205 check_headers.push_back(event);
202 break; 206 break;
203 case TraceItem::TRACE_CHECK_HEADER: 207 case TraceItem::TRACE_CHECK_HEADER:
204 headers_checked++; 208 headers_checked++;
205 break; 209 break;
210 case TraceItem::TRACE_IMPORT_LOAD:
211 case TraceItem::TRACE_IMPORT_BLOCK:
206 case TraceItem::TRACE_SETUP: 212 case TraceItem::TRACE_SETUP:
207 case TraceItem::TRACE_FILE_LOAD: 213 case TraceItem::TRACE_FILE_LOAD:
208 case TraceItem::TRACE_FILE_WRITE: 214 case TraceItem::TRACE_FILE_WRITE:
209 case TraceItem::TRACE_DEFINE_TARGET: 215 case TraceItem::TRACE_DEFINE_TARGET:
210 case TraceItem::TRACE_ON_RESOLVED: 216 case TraceItem::TRACE_ON_RESOLVED:
211 break; // Ignore these for the summary. 217 break; // Ignore these for the summary.
212 } 218 }
213 } 219 }
214 220
215 std::ostringstream out; 221 std::ostringstream out;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 break; 280 break;
275 case TraceItem::TRACE_FILE_PARSE: 281 case TraceItem::TRACE_FILE_PARSE:
276 out << "\"parse\""; 282 out << "\"parse\"";
277 break; 283 break;
278 case TraceItem::TRACE_FILE_EXECUTE: 284 case TraceItem::TRACE_FILE_EXECUTE:
279 out << "\"file_exec\""; 285 out << "\"file_exec\"";
280 break; 286 break;
281 case TraceItem::TRACE_FILE_WRITE: 287 case TraceItem::TRACE_FILE_WRITE:
282 out << "\"file_write\""; 288 out << "\"file_write\"";
283 break; 289 break;
290 case TraceItem::TRACE_IMPORT_LOAD:
291 out << "\"import_load\"";
292 break;
293 case TraceItem::TRACE_IMPORT_BLOCK:
294 out << "\"import_block\"";
295 break;
284 case TraceItem::TRACE_SCRIPT_EXECUTE: 296 case TraceItem::TRACE_SCRIPT_EXECUTE:
285 out << "\"script_exec\""; 297 out << "\"script_exec\"";
286 break; 298 break;
287 case TraceItem::TRACE_DEFINE_TARGET: 299 case TraceItem::TRACE_DEFINE_TARGET:
288 out << "\"define\""; 300 out << "\"define\"";
289 break; 301 break;
290 case TraceItem::TRACE_ON_RESOLVED: 302 case TraceItem::TRACE_ON_RESOLVED:
291 out << "\"onresolved\""; 303 out << "\"onresolved\"";
292 break; 304 break;
293 case TraceItem::TRACE_CHECK_HEADER: 305 case TraceItem::TRACE_CHECK_HEADER:
(...skipping 25 matching lines...) Expand all
319 } 331 }
320 out << "}"; 332 out << "}";
321 } 333 }
322 334
323 out << "]}"; 335 out << "]}";
324 336
325 std::string out_str = out.str(); 337 std::string out_str = out.str();
326 base::WriteFile(file_name, out_str.data(), 338 base::WriteFile(file_name, out_str.data(),
327 static_cast<int>(out_str.size())); 339 static_cast<int>(out_str.size()));
328 } 340 }
OLDNEW
« no previous file with comments | « tools/gn/trace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698