Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 11 #include "base/test/trace_event_analyzer.h" | |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/test/automation/automation_proxy.h" | |
| 14 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 15 #include "chrome/test/ui/javascript_test_util.h" | 17 #include "chrome/test/ui/javascript_test_util.h" |
| 16 #include "chrome/test/ui/ui_perf_test.h" | 18 #include "chrome/test/ui/ui_perf_test.h" |
| 17 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 20 #include "ui/gfx/gl/gl_implementation.h" | |
| 18 #include "ui/gfx/gl/gl_switches.h" | 21 #include "ui/gfx/gl/gl_switches.h" |
| 19 | 22 |
| 20 namespace { | 23 namespace { |
| 21 | 24 |
| 22 enum FrameRateTestFlags { | 25 enum FrameRateTestFlags { |
| 23 kMakeBodyComposited = 1 << 0, | 26 kMakeBodyComposited = 1 << 0, |
| 24 kDisableVsync = 1 << 1, | 27 kDisableVsync = 1 << 1, |
| 25 kDisableGpu = 1 << 2, | 28 kDisableGpu = 1 << 2, |
| 26 kUseReferenceBuild = 1 << 3, | 29 kUseReferenceBuild = 1 << 3, |
| 27 kInternal = 1 << 4, | 30 kInternal = 1 << 4, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 46 public: | 49 public: |
| 47 FrameRateTest() { | 50 FrameRateTest() { |
| 48 show_window_ = true; | 51 show_window_ = true; |
| 49 dom_automation_enabled_ = true; | 52 dom_automation_enabled_ = true; |
| 50 // Since this is a performance test, try to use the host machine's GPU | 53 // Since this is a performance test, try to use the host machine's GPU |
| 51 // instead of falling back to software-rendering. | 54 // instead of falling back to software-rendering. |
| 52 force_use_osmesa_ = false; | 55 force_use_osmesa_ = false; |
| 53 disable_accelerated_compositing_ = false; | 56 disable_accelerated_compositing_ = false; |
| 54 } | 57 } |
| 55 | 58 |
| 59 virtual bool IsReferenceBuild() const { | |
| 60 return (GetParam() & kUseReferenceBuild); | |
| 61 } | |
| 62 | |
| 56 virtual FilePath GetDataPath(const std::string& name) { | 63 virtual FilePath GetDataPath(const std::string& name) { |
| 57 // Make sure the test data is checked out. | 64 // Make sure the test data is checked out. |
| 58 FilePath test_path; | 65 FilePath test_path; |
| 59 PathService::Get(chrome::DIR_TEST_DATA, &test_path); | 66 PathService::Get(chrome::DIR_TEST_DATA, &test_path); |
| 60 test_path = test_path.Append(FILE_PATH_LITERAL("perf")); | 67 test_path = test_path.Append(FILE_PATH_LITERAL("perf")); |
| 61 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate")); | 68 test_path = test_path.Append(FILE_PATH_LITERAL("frame_rate")); |
| 62 if (GetParam() & kInternal) { | 69 if (GetParam() & kInternal) { |
| 63 test_path = test_path.Append(FILE_PATH_LITERAL("private")); | 70 test_path = test_path.Append(FILE_PATH_LITERAL("private")); |
| 64 } else { | 71 } else { |
| 65 test_path = test_path.Append(FILE_PATH_LITERAL("content")); | 72 test_path = test_path.Append(FILE_PATH_LITERAL("content")); |
| 66 } | 73 } |
| 67 test_path = test_path.AppendASCII(name); | 74 test_path = test_path.AppendASCII(name); |
| 68 return test_path; | 75 return test_path; |
| 69 } | 76 } |
| 70 | 77 |
| 71 virtual void SetUp() { | 78 virtual void SetUp() { |
| 72 if (GetParam() & kUseReferenceBuild) { | 79 if (IsReferenceBuild()) { |
| 73 UseReferenceBuild(); | 80 UseReferenceBuild(); |
| 74 } | 81 } |
| 75 | 82 |
| 76 // UI tests boot up render views starting from about:blank. This causes | 83 // UI tests boot up render views starting from about:blank. This causes |
| 77 // the renderer to start up thinking it cannot use the GPU. To work | 84 // the renderer to start up thinking it cannot use the GPU. To work |
| 78 // around that, and allow the frame rate test to use the GPU, we must | 85 // around that, and allow the frame rate test to use the GPU, we must |
| 79 // pass kAllowWebUICompositing. | 86 // pass kAllowWebUICompositing. |
| 80 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); | 87 launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); |
| 81 | 88 |
| 82 if (GetParam() & kDisableGpu) { | 89 if (GetParam() & kDisableGpu) { |
| 83 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing); | 90 launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing); |
| 84 launch_arguments_.AppendSwitch(switches::kDisableExperimentalWebGL); | 91 launch_arguments_.AppendSwitch(switches::kDisableExperimentalWebGL); |
| 85 } | 92 } |
| 86 | 93 |
| 87 if (GetParam() & kDisableVsync) { | 94 if (GetParam() & kDisableVsync) { |
| 88 launch_arguments_.AppendSwitch(switches::kDisableGpuVsync); | 95 launch_arguments_.AppendSwitch(switches::kDisableGpuVsync); |
| 89 } | 96 } |
| 90 | 97 |
| 91 UIPerfTest::SetUp(); | 98 UIPerfTest::SetUp(); |
| 92 } | 99 } |
| 93 | 100 |
| 94 void RunTest(const std::string& name) { | 101 void RunTest(const std::string& name) { |
| 102 using namespace trace_analyzer; | |
|
nduca
2011/11/01 19:17:49
why using here only? That feels anomalous.
jbates
2011/11/03 00:51:07
This is actually done in lots of other chromium co
| |
| 95 FilePath test_path = GetDataPath(name); | 103 FilePath test_path = GetDataPath(name); |
| 96 ASSERT_TRUE(file_util::DirectoryExists(test_path)) | 104 ASSERT_TRUE(file_util::DirectoryExists(test_path)) |
| 97 << "Missing test directory: " << test_path.value(); | 105 << "Missing test directory: " << test_path.value(); |
| 98 | 106 |
| 99 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); | 107 test_path = test_path.Append(FILE_PATH_LITERAL("test.html")); |
| 100 | 108 |
| 101 scoped_refptr<TabProxy> tab(GetActiveTab()); | 109 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 102 ASSERT_TRUE(tab.get()); | 110 ASSERT_TRUE(tab.get()); |
| 103 | 111 |
| 104 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 112 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 105 tab->NavigateToURL(net::FilePathToFileURL(test_path))); | 113 tab->NavigateToURL(net::FilePathToFileURL(test_path))); |
| 106 | 114 |
| 107 if (GetParam() & kMakeBodyComposited) { | 115 if (GetParam() & kMakeBodyComposited) { |
| 108 ASSERT_TRUE(tab->NavigateToURLAsync( | 116 ASSERT_TRUE(tab->NavigateToURLAsync( |
| 109 GURL("javascript:__make_body_composited();"))); | 117 GURL("javascript:__make_body_composited();"))); |
| 110 } | 118 } |
| 111 | 119 |
| 120 // TODO(jbates): remove this check when ref builds are updated. | |
| 121 if (!IsReferenceBuild()) { | |
|
nduca
2011/11/01 19:17:49
Why not just update the ref builds now?
jbates
2011/11/03 00:51:07
Either this needs to be split up into the test cha
jbates
2011/11/04 22:30:39
Actually, thinking this over more... we probably w
| |
| 122 // Start tracing category "test_frame_rate_tests". | |
| 123 ASSERT_TRUE(automation()->BeginTracing("test_frame_rate_tests")); | |
| 124 } | |
| 125 | |
| 112 // Block until initialization completes. | 126 // Block until initialization completes. |
| 113 ASSERT_TRUE(WaitUntilJavaScriptCondition( | 127 ASSERT_TRUE(WaitUntilJavaScriptCondition( |
| 114 tab, L"", L"window.domAutomationController.send(__initialized);", | 128 tab, L"", L"window.domAutomationController.send(__initialized);", |
| 115 TestTimeouts::large_test_timeout_ms())); | 129 TestTimeouts::large_test_timeout_ms())); |
| 116 | 130 |
| 117 // Start the tests. | 131 // Start the tests. |
| 118 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); | 132 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); |
| 119 | 133 |
| 120 // Block until the tests completes. | 134 // Block until the tests completes. |
| 121 ASSERT_TRUE(WaitUntilJavaScriptCondition( | 135 ASSERT_TRUE(WaitUntilJavaScriptCondition( |
| 122 tab, L"", L"window.domAutomationController.send(!__running_all);", | 136 tab, L"", L"window.domAutomationController.send(!__running_all);", |
| 123 TestTimeouts::large_test_timeout_ms())); | 137 TestTimeouts::large_test_timeout_ms())); |
| 124 | 138 |
| 139 std::string json_events; | |
| 140 // TODO(jbates): remove this check when ref builds are updated. | |
| 141 if (!IsReferenceBuild()) { | |
| 142 // Stop tracing. | |
| 143 ASSERT_TRUE(automation()->EndTracing(&json_events)); | |
| 144 } | |
| 145 | |
| 125 // Read out the results. | 146 // Read out the results. |
| 126 std::wstring json; | 147 std::wstring json; |
| 127 ASSERT_TRUE(tab->ExecuteAndExtractString( | 148 ASSERT_TRUE(tab->ExecuteAndExtractString( |
| 128 L"", | 149 L"", |
| 129 L"window.domAutomationController.send(" | 150 L"window.domAutomationController.send(" |
| 130 L"JSON.stringify(__calc_results_total()));", | 151 L"JSON.stringify(__calc_results_total()));", |
| 131 &json)); | 152 &json)); |
| 132 | 153 |
| 133 std::map<std::string, std::string> results; | 154 std::map<std::string, std::string> results; |
| 134 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results)); | 155 ASSERT_TRUE(JsonDictionaryToMap(WideToUTF8(json), &results)); |
| 135 | 156 |
| 136 ASSERT_TRUE(results.find("mean") != results.end()); | 157 ASSERT_TRUE(results.find("mean") != results.end()); |
| 137 ASSERT_TRUE(results.find("sigma") != results.end()); | 158 ASSERT_TRUE(results.find("sigma") != results.end()); |
| 138 ASSERT_TRUE(results.find("gestures") != results.end()); | 159 ASSERT_TRUE(results.find("gestures") != results.end()); |
| 139 ASSERT_TRUE(results.find("means") != results.end()); | 160 ASSERT_TRUE(results.find("means") != results.end()); |
| 140 ASSERT_TRUE(results.find("sigmas") != results.end()); | 161 ASSERT_TRUE(results.find("sigmas") != results.end()); |
| 141 | 162 |
| 163 std::string gpu_suffix; | |
| 164 // TODO(jbates): remove this check when ref builds are updated. | |
| 165 if (!IsReferenceBuild()) { | |
| 166 // Check trace for GPU accleration. | |
|
nduca
2011/11/01 19:17:49
I can haz new function?
jbates
2011/11/03 00:51:07
Done.
| |
| 167 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events)); | |
| 168 const TraceEvent* gpu_event = analyzer->FindOneEvent( | |
| 169 Query(EVENT_NAME) == Query::String("SwapBuffers") && | |
| 170 Query(EVENT_HAS_ARG, "GLImpl")); | |
| 171 gfx::GLImplementation gl_impl = gfx::kGLImplementationNone; | |
| 172 if (gpu_event) | |
| 173 gpu_event->GetArgAsIntType("GLImpl", &gl_impl); | |
| 174 bool is_GPU = (gl_impl == gfx::kGLImplementationDesktopGL || | |
| 175 gl_impl == gfx::kGLImplementationEGLGLES2); | |
| 176 | |
| 177 // Verify that sanity-check DoDeferredUpdate event exists. | |
| 178 ASSERT_TRUE(analyzer->FindOneEvent(Query(EVENT_NAME) == | |
| 179 Query::String("DoDeferredUpdate"))); | |
| 180 | |
| 181 // If GPU acceleration is requested, set the appropriate suffix. | |
| 182 // _swfb means software fallback (GPU acceleration requested but not | |
| 183 // available). | |
| 184 if (is_GPU) | |
| 185 gpu_suffix = "_gpu"; | |
| 186 else if (GetParam() & kMakeBodyComposited) | |
| 187 gpu_suffix = "_swfb"; | |
|
nduca
2011/11/01 19:17:49
Will we still have the _comp suffix? WE have an ex
jbates
2011/11/03 00:51:07
I got rid of swfb, because we can infer that from
| |
| 188 } | |
| 189 | |
| 142 std::string trace_name = "fps"; | 190 std::string trace_name = "fps"; |
| 143 trace_name += GetSuffixForTestFlags(GetParam()); | 191 trace_name += GetSuffixForTestFlags(GetParam()) + gpu_suffix; |
|
nduca
2011/11/01 19:17:49
Merge this with the GetSuffixForTest bit? E.g. Get
jbates
2011/11/03 00:51:07
Done.
| |
| 144 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(), | 192 printf("GESTURES %s: %s= [%s] [%s] [%s]\n", name.c_str(), |
| 145 trace_name.c_str(), | 193 trace_name.c_str(), |
| 146 results["gestures"].c_str(), | 194 results["gestures"].c_str(), |
| 147 results["means"].c_str(), | 195 results["means"].c_str(), |
| 148 results["sigmas"].c_str()); | 196 results["sigmas"].c_str()); |
| 149 | 197 |
| 150 std::string mean_and_error = results["mean"] + "," + results["sigma"]; | 198 std::string mean_and_error = results["mean"] + "," + results["sigma"]; |
| 151 PrintResultMeanAndError(name, "", trace_name, mean_and_error, | 199 PrintResultMeanAndError(name, "", trace_name, mean_and_error, |
| 152 "frames-per-second", true); | 200 "frames-per-second", true); |
| 153 } | 201 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 kInternal, | 249 kInternal, |
| 202 kInternal | kDisableVsync, | 250 kInternal | kDisableVsync, |
| 203 kInternal | kDisableGpu, | 251 kInternal | kDisableGpu, |
| 204 kInternal | kUseReferenceBuild, | 252 kInternal | kUseReferenceBuild, |
| 205 kInternal | kDisableVsync | kUseReferenceBuild)); | 253 kInternal | kDisableVsync | kUseReferenceBuild)); |
| 206 | 254 |
| 207 INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(fishbowl) | 255 INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(fishbowl) |
| 208 INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(speedreading) | 256 INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(speedreading) |
| 209 | 257 |
| 210 } // namespace | 258 } // namespace |
| OLD | NEW |