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

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

Issue 265693003: Redo GN "args" command (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: create dir Created 6 years, 7 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 | Annotate | Revision Log
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 <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <sstream> 9 #include <sstream>
10 #include <vector> 10 #include <vector>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (!done_) { 160 if (!done_) {
161 done_ = true; 161 done_ = true;
162 if (trace_log) { 162 if (trace_log) {
163 item_->set_end(base::TimeTicks::HighResNow()); 163 item_->set_end(base::TimeTicks::HighResNow());
164 AddTrace(item_); 164 AddTrace(item_);
165 } 165 }
166 } 166 }
167 } 167 }
168 168
169 void EnableTracing() { 169 void EnableTracing() {
170 CHECK(!trace_log); 170 if (!trace_log)
171 trace_log = new TraceLog; 171 trace_log = new TraceLog;
172 } 172 }
173 173
174 void AddTrace(TraceItem* item) { 174 void AddTrace(TraceItem* item) {
175 trace_log->Add(item); 175 trace_log->Add(item);
176 } 176 }
177 177
178 std::string SummarizeTraces() { 178 std::string SummarizeTraces() {
179 if (!trace_log) 179 if (!trace_log)
180 return std::string(); 180 return std::string();
181 181
(...skipping 15 matching lines...) Expand all
197 break; 197 break;
198 case TraceItem::TRACE_SCRIPT_EXECUTE: 198 case TraceItem::TRACE_SCRIPT_EXECUTE:
199 script_execs.push_back(events[i]); 199 script_execs.push_back(events[i]);
200 break; 200 break;
201 case TraceItem::TRACE_CHECK_HEADERS: 201 case TraceItem::TRACE_CHECK_HEADERS:
202 check_headers.push_back(events[i]); 202 check_headers.push_back(events[i]);
203 break; 203 break;
204 case TraceItem::TRACE_CHECK_HEADER: 204 case TraceItem::TRACE_CHECK_HEADER:
205 headers_checked++; 205 headers_checked++;
206 break; 206 break;
207 case TraceItem::TRACE_SETUP:
207 case TraceItem::TRACE_FILE_LOAD: 208 case TraceItem::TRACE_FILE_LOAD:
208 case TraceItem::TRACE_FILE_WRITE: 209 case TraceItem::TRACE_FILE_WRITE:
209 case TraceItem::TRACE_DEFINE_TARGET: 210 case TraceItem::TRACE_DEFINE_TARGET:
210 break; // Ignore these for the summary. 211 break; // Ignore these for the summary.
211 } 212 }
212 } 213 }
213 214
214 std::ostringstream out; 215 std::ostringstream out;
215 SummarizeParses(parses, out); 216 SummarizeParses(parses, out);
216 out << std::endl; 217 out << std::endl;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 out << ",\"ts\":" << item.begin().ToInternalValue(); 259 out << ",\"ts\":" << item.begin().ToInternalValue();
259 out << ",\"ph\":\"X\""; // "X" = complete event with begin & duration. 260 out << ",\"ph\":\"X\""; // "X" = complete event with begin & duration.
260 out << ",\"dur\":" << item.delta().InMicroseconds(); 261 out << ",\"dur\":" << item.delta().InMicroseconds();
261 262
262 quote_buffer.resize(0); 263 quote_buffer.resize(0);
263 base::EscapeJSONString(item.name(), true, &quote_buffer); 264 base::EscapeJSONString(item.name(), true, &quote_buffer);
264 out << ",\"name\":" << quote_buffer; 265 out << ",\"name\":" << quote_buffer;
265 266
266 out << ",\"cat\":"; 267 out << ",\"cat\":";
267 switch (item.type()) { 268 switch (item.type()) {
269 case TraceItem::TRACE_SETUP:
270 out << "\"setup\"";
271 break;
268 case TraceItem::TRACE_FILE_LOAD: 272 case TraceItem::TRACE_FILE_LOAD:
269 out << "\"load\""; 273 out << "\"load\"";
270 break; 274 break;
271 case TraceItem::TRACE_FILE_PARSE: 275 case TraceItem::TRACE_FILE_PARSE:
272 out << "\"parse\""; 276 out << "\"parse\"";
273 break; 277 break;
274 case TraceItem::TRACE_FILE_EXECUTE: 278 case TraceItem::TRACE_FILE_EXECUTE:
275 out << "\"file_exec\""; 279 out << "\"file_exec\"";
276 break; 280 break;
277 case TraceItem::TRACE_FILE_WRITE: 281 case TraceItem::TRACE_FILE_WRITE:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 316 }
313 out << "}"; 317 out << "}";
314 } 318 }
315 319
316 out << "]}"; 320 out << "]}";
317 321
318 std::string out_str = out.str(); 322 std::string out_str = out.str();
319 base::WriteFile(file_name, out_str.data(), 323 base::WriteFile(file_name, out_str.data(),
320 static_cast<int>(out_str.size())); 324 static_cast<int>(out_str.size()));
321 } 325 }
OLDNEW
« tools/gn/setup.cc ('K') | « tools/gn/trace.h ('k') | tools/gn/value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698