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

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

Issue 1305193002: Trace-based benchmarking via a mojo app. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Further address Etienne's comments. Created 5 years, 3 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 | « apps/benchmark/event.cc ('k') | apps/benchmark/measurements.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <vector>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace benchmark {
12
13 namespace {
14
15 TEST(GetEventsTest, Empty) {
16 std::vector<Event> events;
17 EXPECT_TRUE(GetEvents("[]", &events));
18 EXPECT_EQ(0u, events.size());
19 }
20
21 TEST(GetEventsTest, Invalid) {
22 std::vector<Event> events;
23 EXPECT_FALSE(GetEvents("", &events));
24 EXPECT_FALSE(GetEvents("[", &events));
25 EXPECT_FALSE(GetEvents("]", &events));
26 EXPECT_FALSE(GetEvents("[,]", &events));
27 }
28
29 TEST(GetEventsTest, Typical) {
30 std::string event1 =
31 "{\"pid\":7845,\"tid\":7845,\"ts\":1988539886444,"
32 "\"ph\":\"X\",\"cat\":\"toplevel\",\"name\":\"MessageLoop::RunTask\","
33 "\"args\":{\"src_file\":\"../../mojo/message_pump/handle_watcher.cc\","
34 "\"src_func\":\"RemoveAndNotify\"},\"dur\":647,\"tdur\":633,"
35 "\"tts\":25295}";
36 std::string event2 =
37 "{\"pid\":8238,\"tid\":8264,\"ts\":1988975370433,\"ph\":\"X\","
38 "\"cat\":\"gpu\",\"name\":\"GLES2::WaitForCmd\",\"args\":{},\"dur\":7288,"
39 "\"tdur\":212,\"tts\":6368}";
40
41 std::string trace_json = "[" + event1 + "," + event2 + "]";
42 std::vector<Event> events;
43 ASSERT_TRUE(GetEvents(trace_json, &events));
44 ASSERT_EQ(2u, events.size());
45
46 EXPECT_EQ("MessageLoop::RunTask", events[0].name);
47 EXPECT_EQ("toplevel", events[0].category);
48 EXPECT_EQ(base::TimeTicks::FromInternalValue(1988539886444),
49 events[0].timestamp);
50 EXPECT_EQ(base::TimeDelta::FromInternalValue(647), events[0].duration);
51
52 EXPECT_EQ("GLES2::WaitForCmd", events[1].name);
53 EXPECT_EQ("gpu", events[1].category);
54 EXPECT_EQ(base::TimeTicks::FromInternalValue(1988975370433),
55 events[1].timestamp);
56 EXPECT_EQ(base::TimeDelta::FromInternalValue(7288), events[1].duration);
57 }
58
59 TEST(GetEventsTest, NoDuration) {
60 std::string event =
61 "{\"pid\":8238,\"tid\":8238,\"ts\":1988978463403,\"ph\":\"X\","
62 "\"cat\":\"toplevel\",\"name\":\"MessageLoop::RunTask\",\"args\":"
63 "{\"src_file\":\"../../mojo/message_pump/handle_watcher.cc\","
64 "\"src_func\":\"RemoveAndNotify\"},\"tdur\":0,\"tts\":22812}";
65
66 std::string trace_json = "[" + event + "]";
67 std::vector<Event> events;
68 ASSERT_TRUE(GetEvents(trace_json, &events));
69 ASSERT_EQ(1u, events.size());
70
71 EXPECT_EQ("MessageLoop::RunTask", events[0].name);
72 EXPECT_EQ("toplevel", events[0].category);
73 EXPECT_EQ(base::TimeTicks::FromInternalValue(1988978463403),
74 events[0].timestamp);
75 EXPECT_EQ(base::TimeDelta::FromInternalValue(0), events[0].duration);
76 }
77
78 } // namespace
79
80 } // namespace benchmark
OLDNEW
« no previous file with comments | « apps/benchmark/event.cc ('k') | apps/benchmark/measurements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698