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

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

Issue 1305193002: Trace-based benchmarking via a mojo app. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "apps/benchmark/event.h"
6
7 namespace benchmark {
8
9 Event::Event() {}
10
11 Event::~Event() {}
12
13 bool GetEvents(scoped_ptr<base::Value> trace_data, std::vector<Event>* result) {
14 result->clear();
15
16 base::ListValue* event_list;
17 if (!trace_data->GetAsList(&event_list))
18 return false;
19
20 for (base::Value* val : *event_list) {
21 Event event;
22 base::DictionaryValue* dict;
23 if (!val->GetAsDictionary(&dict))
24 return false;
25
26 if (!dict->GetString("name", &event.name))
27 return false;
28
29 if (!dict->GetString("cat", &event.category))
30 return false;
31
32 double timestamp;
33 if (!dict->GetDouble("ts", &timestamp))
34 return false;
35 event.timestamp = base::TimeTicks::FromInternalValue(timestamp);
36
37 // It is valid for an event to not have duration.
38 double duration;
39 if (!dict->GetDouble("dur", &duration)) {
40 event.duration = base::TimeDelta();
41 } else {
42 event.duration = base::TimeDelta::FromInternalValue(duration);
43 }
44
45 result->push_back(event);
46 }
47 return true;
48 }
49 } // namespace benchmark
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698