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

Side by Side Diff: chrome/test/perf/frame_rate/frame_rate_tests.cc

Issue 7982007: add "did it run on GPU" check to frame_rate_tests.cc using AutomationProxy tracing feature (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 9 years, 1 month 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
« no previous file with comments | « no previous file | content/renderer/render_widget.cc » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 5 #include <map>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
12 #include "base/test/trace_event_analyzer.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/automation/automation_proxy.h"
15 #include "chrome/test/automation/tab_proxy.h" 17 #include "chrome/test/automation/tab_proxy.h"
16 #include "chrome/test/ui/javascript_test_util.h" 18 #include "chrome/test/ui/javascript_test_util.h"
17 #include "chrome/test/ui/ui_perf_test.h" 19 #include "chrome/test/ui/ui_perf_test.h"
18 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
21 #include "ui/gfx/gl/gl_implementation.h"
19 #include "ui/gfx/gl/gl_switches.h" 22 #include "ui/gfx/gl/gl_switches.h"
20 23
21 namespace { 24 namespace {
22 25
23 enum FrameRateTestFlags { 26 enum FrameRateTestFlags {
24 kRequiresGpu = 1 << 0, // only execute test if --enable-gpu 27 kRequiresGpu = 1 << 0, // only execute test if --enable-gpu
25 kDisableGpu = 1 << 1, // run test without gpu acceleration 28 kDisableGpu = 1 << 1, // run test without gpu acceleration
26 kMakeBodyComposited = 1 << 2, // force the test to use the compositor 29 kMakeBodyComposited = 1 << 2, // force the test to use the compositor
27 kDisableVsync = 1 << 3, // do not lock animation on vertical refresh 30 kDisableVsync = 1 << 3, // do not lock animation on vertical refresh
28 kUseReferenceBuild = 1 << 4, // run test using the reference chrome build 31 kUseReferenceBuild = 1 << 4, // run test using the reference chrome build
29 kInternal = 1 << 5, // Test uses internal test data 32 kInternal = 1 << 5, // Test uses internal test data
30 kHasRedirect = 1 << 6, // Test page contains an HTML redirect 33 kHasRedirect = 1 << 6, // Test page contains an HTML redirect
31 }; 34 };
32 35
33 std::string GetSuffixForTestFlags(int flags) { 36 std::string GetSuffixForTestFlags(int flags, bool did_run_on_gpu) {
34 std::string suffix; 37 std::string suffix;
35 if (flags & kMakeBodyComposited) 38 if (flags & kMakeBodyComposited)
36 suffix += "_comp"; 39 suffix += "_comp";
37 if (flags & kDisableVsync) 40 if (flags & kDisableVsync)
38 suffix += "_novsync"; 41 suffix += "_novsync";
39 if (flags & kDisableGpu) 42 if (flags & kDisableGpu)
40 suffix += "_nogpu"; 43 suffix += "_nogpu";
nduca 2011/11/08 00:27:42 does the _nogpu get affected? Can we reconcile the
jbates 2011/11/09 02:14:46 Done.
41 if (flags & kUseReferenceBuild) 44 if (flags & kUseReferenceBuild)
42 suffix += "_ref"; 45 suffix += "_ref";
46 if (did_run_on_gpu)
47 suffix += "_gpu";
43 return suffix; 48 return suffix;
44 } 49 }
45 50
46 class FrameRateTest 51 class FrameRateTest
47 : public UIPerfTest 52 : public UIPerfTest
48 , public ::testing::WithParamInterface<int> { 53 , public ::testing::WithParamInterface<int> {
49 public: 54 public:
50 FrameRateTest() { 55 FrameRateTest() {
51 show_window_ = true; 56 show_window_ = true;
52 dom_automation_enabled_ = true; 57 dom_automation_enabled_ = true;
53 } 58 }
54 59
60 virtual bool IsReferenceBuild() const {
61 return (GetParam() & kUseReferenceBuild);
62 }
63
55 virtual FilePath GetDataPath(const std::string& name) { 64 virtual FilePath GetDataPath(const std::string& name) {
56 // Make sure the test data is checked out. 65 // Make sure the test data is checked out.
57 FilePath test_path; 66 FilePath test_path;
58 PathService::Get(chrome::DIR_TEST_DATA, &test_path); 67 PathService::Get(chrome::DIR_TEST_DATA, &test_path);
59 test_path = test_path.Append(FILE_PATH_LITERAL("perf")); 68 test_path = test_path.Append(FILE_PATH_LITERAL("perf"));
60 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate")); 69 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate"));
61 if (GetParam() & kInternal) { 70 if (GetParam() & kInternal) {
62 test_path = test_path.Append(FILE_PATH_LITERAL("private")); 71 test_path = test_path.Append(FILE_PATH_LITERAL("private"));
63 } else { 72 } else {
64 test_path = test_path.Append(FILE_PATH_LITERAL("content")); 73 test_path = test_path.Append(FILE_PATH_LITERAL("content"));
65 } 74 }
66 test_path = test_path.AppendASCII(name); 75 test_path = test_path.AppendASCII(name);
67 return test_path; 76 return test_path;
68 } 77 }
69 78
70 virtual void SetUp() { 79 virtual void SetUp() {
71 if (GetParam() & kUseReferenceBuild) { 80 if (IsReferenceBuild()) {
72 UseReferenceBuild(); 81 UseReferenceBuild();
73 } 82 }
74 83
75 // UI tests boot up render views starting from about:blank. This causes 84 // UI tests boot up render views starting from about:blank. This causes
76 // the renderer to start up thinking it cannot use the GPU. To work 85 // the renderer to start up thinking it cannot use the GPU. To work
77 // around that, and allow the frame rate test to use the GPU, we must 86 // around that, and allow the frame rate test to use the GPU, we must
78 // pass kAllowWebUICompositing. 87 // pass kAllowWebUICompositing.
79 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); 88 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing);
80 89
81 // Some of the tests may launch http requests through JSON or AJAX 90 // Some of the tests may launch http requests through JSON or AJAX
(...skipping 12 matching lines...) Expand all
94 launch_arguments_.AppendSwitch(switches::kEnableAccelerated2dCanvas); 103 launch_arguments_.AppendSwitch(switches::kEnableAccelerated2dCanvas);
95 } 104 }
96 105
97 if (GetParam() & kDisableVsync) { 106 if (GetParam() & kDisableVsync) {
98 launch_arguments_.AppendSwitch(switches::kDisableGpuVsync); 107 launch_arguments_.AppendSwitch(switches::kDisableGpuVsync);
99 } 108 }
100 109
101 UIPerfTest::SetUp(); 110 UIPerfTest::SetUp();
102 } 111 }
103 112
113 bool DidRunOnGpu(const std::string& json_events) {
114 using namespace trace_analyzer;
115
116 // TODO(jbates): remove this check when ref builds are updated.
117 if (IsReferenceBuild())
118 return false;
119
120 // Check trace for GPU accleration.
121 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events));
122 // Verify that sanity-check DoDeferredUpdate event exists.
123 EXPECT_TRUE(analyzer->FindOneEvent(Query(EVENT_NAME) ==
124 Query::String("DoDeferredUpdate")));
125
126 gfx::GLImplementation gl_impl = gfx::kGLImplementationNone;
127 const TraceEvent* gpu_event = analyzer->FindOneEvent(
128 Query(EVENT_NAME) == Query::String("SwapBuffers") &&
129 Query(EVENT_HAS_NUMBER_ARG, "GLImpl"));
130 if (gpu_event)
131 gl_impl = static_cast<gfx::GLImplementation>(
132 gpu_event->GetKnownArgAsInt("GLImpl"));
133 return (gl_impl == gfx::kGLImplementationDesktopGL ||
134 gl_impl == gfx::kGLImplementationEGLGLES2);
135 }
136
104 void RunTest(const std::string& name) { 137 void RunTest(const std::string& name) {
105 if ((GetParam() & kRequiresGpu) && 138 if ((GetParam() & kRequiresGpu) &&
106 !CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu")) { 139 !CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu")) {
107 printf("Test skipped: requires gpu\n"); 140 printf("Test skipped: requires gpu\n");
108 return; 141 return;
109 } 142 }
110 FilePath test_path = GetDataPath(name); 143 FilePath test_path = GetDataPath(name);
111 ASSERT_TRUE(file_util::DirectoryExists(test_path)) 144 ASSERT_TRUE(file_util::DirectoryExists(test_path))
112 << "Missing test directory: " << test_path.value(); 145 << "Missing test directory: " << test_path.value();
113 146
(...skipping 25 matching lines...) Expand all
139 // that flag kHasRedirect is enabled for the current test. 172 // that flag kHasRedirect is enabled for the current test.
140 ASSERT_TRUE(WaitUntilJavaScriptCondition( 173 ASSERT_TRUE(WaitUntilJavaScriptCondition(
141 tab, L"", L"window.domAutomationController.send(__initialized);", 174 tab, L"", L"window.domAutomationController.send(__initialized);",
142 TestTimeouts::large_test_timeout_ms())); 175 TestTimeouts::large_test_timeout_ms()));
143 176
144 if (GetParam() & kMakeBodyComposited) { 177 if (GetParam() & kMakeBodyComposited) {
145 ASSERT_TRUE(tab->NavigateToURLAsync( 178 ASSERT_TRUE(tab->NavigateToURLAsync(
146 GURL("javascript:__make_body_composited();"))); 179 GURL("javascript:__make_body_composited();")));
147 } 180 }
148 181
182 // TODO(jbates): remove this check when ref builds are updated.
183 if (!IsReferenceBuild())
184 ASSERT_TRUE(automation()->BeginTracing("test_frame_rate_tests"));
185
149 // Start the tests. 186 // Start the tests.
150 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); 187 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();")));
151 188
152 // Block until the tests completes. 189 // Block until the tests completes.
153 ASSERT_TRUE(WaitUntilJavaScriptCondition( 190 ASSERT_TRUE(WaitUntilJavaScriptCondition(
154 tab, L"", L"window.domAutomationController.send(!__running_all);", 191 tab, L"", L"window.domAutomationController.send(!__running_all);",
155 TestTimeouts::large_test_timeout_ms())); 192 TestTimeouts::large_test_timeout_ms()));
156 193
194 // TODO(jbates): remove this check when ref builds are updated.
195 std::string json_events;
196 if (!IsReferenceBuild())
197 ASSERT_TRUE(automation()->EndTracing(&json_events));
198
157 // Read out the results. 199 // Read out the results.
158 std::wstring json; 200 std::wstring json;
159 ASSERT_TRUE(tab->ExecuteAndExtractString( 201 ASSERT_TRUE(tab->ExecuteAndExtractString(
160 L"", 202 L"",
161 L"window.domAutomationController.send(" 203 L"window.domAutomationController.send("
162 L"JSON.stringify(__calc_results_total()));", 204 L"JSON.stringify(__calc_results_total()));",
163 &json)); 205 &json));
164 206
165 std::map<std::string, std::string> results; 207 std::map<std::string, std::string> results;
166 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results)); 208 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results));
167 209
168 ASSERT_TRUE(results.find("mean") != results.end()); 210 ASSERT_TRUE(results.find("mean") != results.end());
169 ASSERT_TRUE(results.find("sigma") != results.end()); 211 ASSERT_TRUE(results.find("sigma") != results.end());
170 ASSERT_TRUE(results.find("gestures") != results.end()); 212 ASSERT_TRUE(results.find("gestures") != results.end());
171 ASSERT_TRUE(results.find("means") != results.end()); 213 ASSERT_TRUE(results.find("means") != results.end());
172 ASSERT_TRUE(results.find("sigmas") != results.end()); 214 ASSERT_TRUE(results.find("sigmas") != results.end());
173 215
174 std::string trace_name = "fps"; 216 std::string trace_name = "fps";
175 trace_name += GetSuffixForTestFlags(GetParam()); 217 trace_name += GetSuffixForTestFlags(GetParam(), DidRunOnGpu(json_events));
Justin Novosad 2011/11/08 14:58:43 Currently, the set of tests that run on the gpu ar
jbates 2011/11/09 02:14:46 Done as discussed.
176 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(), 218 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(),
177 trace_name.c_str(), 219 trace_name.c_str(),
178 results["gestures"].c_str(), 220 results["gestures"].c_str(),
179 results["means"].c_str(), 221 results["means"].c_str(),
180 results["sigmas"].c_str()); 222 results["sigmas"].c_str());
181 223
182 std::string mean_and_error = results["mean"] + "," + results["sigma"]; 224 std::string mean_and_error = results["mean"] + "," + results["sigma"];
183 PrintResultMeanAndError(name, "", trace_name, mean_and_error, 225 PrintResultMeanAndError(name, "", trace_name, mean_and_error,
184 "frames-per-second", true); 226 "frames-per-second", true);
185 } 227 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 kInternal | kHasRedirect | kUseReferenceBuild | 286 kInternal | kHasRedirect | kUseReferenceBuild |
245 kRequiresGpu, 287 kRequiresGpu,
246 kInternal | kHasRedirect | kDisableVsync | 288 kInternal | kHasRedirect | kDisableVsync |
247 kRequiresGpu | kUseReferenceBuild)); 289 kRequiresGpu | kUseReferenceBuild));
248 290
249 INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(fireflies) 291 INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(fireflies)
250 INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(FishIE) 292 INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(FishIE)
251 INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(speedreading) 293 INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(speedreading)
252 294
253 } // namespace 295 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698