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

Side by Side Diff: apps/benchmark/event.cc

Issue 1665823003: Only enable the Dart timeline for benchmarks (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | mojo/dart/embedder/dart_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "apps/benchmark/event.h" 5 #include "apps/benchmark/event.h"
6 6
7 #include <map> 7 #include <map>
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 return true; 186 return true;
187 } 187 }
188 188
189 bool ParseEvents(base::ListValue* event_list, std::vector<Event>* result) { 189 bool ParseEvents(base::ListValue* event_list, std::vector<Event>* result) {
190 result->clear(); 190 result->clear();
191 191
192 for (base::Value* val : *event_list) { 192 for (base::Value* val : *event_list) {
193 base::DictionaryValue* event_dict; 193 base::DictionaryValue* event_dict;
194 if (!val->GetAsDictionary(&event_dict)) { 194 if (!val->GetAsDictionary(&event_dict)) {
195 LOG(WARNING) << "Ignoring incorrect trace event (not a dictionary)"; 195 LOG(WARNING) << "Ignoring incorrect trace event (not a dictionary)";
196 LOG(WARNING) << *event_dict;
196 continue; 197 continue;
197 } 198 }
198 199
199 Event event; 200 Event event;
200 201
201 std::string phase; 202 std::string phase;
202 if (!event_dict->GetString("ph", &phase)) { 203 if (!event_dict->GetString("ph", &phase)) {
203 LOG(WARNING) << "Ignoring incorrect trace event (missing phase)"; 204 LOG(WARNING) << "Ignoring incorrect trace event (missing phase)";
205 LOG(WARNING) << *event_dict;
204 continue; 206 continue;
205 } 207 }
206 if (phase == "X") { 208 if (phase == "X") {
207 event.type = EventType::COMPLETE; 209 event.type = EventType::COMPLETE;
208 } else if (phase == "I" || phase == "n") { 210 } else if (phase == "I" || phase == "n") {
209 event.type = EventType::INSTANT; 211 event.type = EventType::INSTANT;
210 } else { 212 } else {
211 // Skip all event types we do not handle. 213 // Skip all event types we do not handle.
212 continue; 214 continue;
213 } 215 }
214 216
215 if (!event_dict->GetString("name", &event.name)) { 217 if (!event_dict->GetString("name", &event.name)) {
216 LOG(ERROR) << "Incorrect trace event (no name)"; 218 LOG(ERROR) << "Incorrect trace event (no name)";
219 LOG(ERROR) << *event_dict;
217 return false; 220 return false;
218 } 221 }
219 222
220 // Some clients do not add categories to events, but we don't want to fail 223 // Some clients do not add categories to events, but we don't want to fail
221 // nor skip the event. 224 // nor skip the event.
222 event_dict->GetString("cat", &event.categories); 225 event_dict->GetString("cat", &event.categories);
223 226
224 double timestamp; 227 double timestamp;
225 if (!event_dict->GetDouble("ts", &timestamp)) { 228 if (!event_dict->GetDouble("ts", &timestamp)) {
226 LOG(WARNING) << "Ingoring incorrect trace event (no timestamp)"; 229 LOG(WARNING) << "Ingoring incorrect trace event (no timestamp)";
230 LOG(WARNING) << *event_dict;
227 continue; 231 continue;
228 } 232 }
229 event.timestamp = base::TimeTicks::FromInternalValue(timestamp); 233 event.timestamp = base::TimeTicks::FromInternalValue(timestamp);
230 234
231 if (event.type == EventType::COMPLETE) { 235 if (event.type == EventType::COMPLETE) {
232 double duration; 236 double duration;
233 if (!event_dict->GetDouble("dur", &duration)) { 237 if (!event_dict->GetDouble("dur", &duration)) {
234 LOG(WARNING) << "Ignoring incorrect complete event (no duration)"; 238 LOG(WARNING) << "Ignoring incorrect complete event (no duration)";
239 LOG(WARNING) << *event_dict;
235 continue; 240 continue;
236 } 241 }
237 242
238 event.duration = base::TimeDelta::FromInternalValue(duration); 243 event.duration = base::TimeDelta::FromInternalValue(duration);
239 } else { 244 } else {
240 event.duration = base::TimeDelta(); 245 event.duration = base::TimeDelta();
241 } 246 }
242 247
243 result->push_back(event); 248 result->push_back(event);
244 } 249 }
(...skipping 19 matching lines...) Expand all
264 } 269 }
265 270
266 if (!JoinEvents(event_list)) 271 if (!JoinEvents(event_list))
267 return false; 272 return false;
268 273
269 if (!ParseEvents(event_list, result)) 274 if (!ParseEvents(event_list, result))
270 return false; 275 return false;
271 return true; 276 return true;
272 } 277 }
273 } // namespace benchmark 278 } // namespace benchmark
OLDNEW
« no previous file with comments | « no previous file | mojo/dart/embedder/dart_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698