diff options
author | sullivan@chromium.org <sullivan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-03 20:17:49 +0000 |
---|---|---|
committer | sullivan@chromium.org <sullivan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-03 20:17:49 +0000 |
commit | 1f4c2abb3829eb68a4363f83a75c3382acaaed42 (patch) | |
tree | 15ad22a191a56cf6488fbcc9e4305ebca6549230 | |
parent | c993cd687a859491e9d43508b32603347a815d68 (diff) | |
download | chromium_src-1f4c2abb3829eb68a4363f83a75c3382acaaed42.zip chromium_src-1f4c2abb3829eb68a4363f83a75c3382acaaed42.tar.gz chromium_src-1f4c2abb3829eb68a4363f83a75c3382acaaed42.tar.bz2 |
Add automation for Kraken benchmark.
Add a KrakenBenchmarkTest class that launches the test and gets the results.
Add a kraken_benchmark_uitest.js file that sets a cookie when the test is complete and adds a function to return the results.
BUG=
TEST=
Review URL: http://codereview.chromium.org/10314012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135199 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/test/data/third_party/kraken/hosted/analyze-results.js | 1 | ||||
-rw-r--r-- | chrome/test/data/third_party/kraken/hosted/kraken-1.1/results.html | 1 | ||||
-rw-r--r-- | chrome/test/perf/kraken_benchmark_uitest.cc | 121 | ||||
-rw-r--r-- | chrome/test/perf/kraken_benchmark_uitest.js | 22 |
5 files changed, 146 insertions, 0 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 8c7f988..0325393 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -3801,6 +3801,7 @@ 'test/perf/dromaeo_benchmark_uitest.cc', 'test/perf/feature_startup_test.cc', 'test/perf/frame_rate/frame_rate_tests.cc', + 'test/perf/kraken_benchmark_uitest.cc', 'test/perf/memory_test.cc', 'test/perf/page_cycler_test.cc', 'test/perf/shutdown_test.cc', diff --git a/chrome/test/data/third_party/kraken/hosted/analyze-results.js b/chrome/test/data/third_party/kraken/hosted/analyze-results.js index 86a6ed6..8354f4f 100644 --- a/chrome/test/data/third_party/kraken/hosted/analyze-results.js +++ b/chrome/test/data/third_party/kraken/hosted/analyze-results.js @@ -273,3 +273,4 @@ computeMeans(); computeStdDevs(); computeStdErrors(); printOutput(); +automation.setDone(); diff --git a/chrome/test/data/third_party/kraken/hosted/kraken-1.1/results.html b/chrome/test/data/third_party/kraken/hosted/kraken-1.1/results.html index 4a5cb32..e89e518 100644 --- a/chrome/test/data/third_party/kraken/hosted/kraken-1.1/results.html +++ b/chrome/test/data/third_party/kraken/hosted/kraken-1.1/results.html @@ -53,6 +53,7 @@ </div> </div> <script src="../json2.js"></script> +<script src="../../../../../perf/kraken_benchmark_uitest.js"></script> <script> //XXX generate this automatically diff --git a/chrome/test/perf/kraken_benchmark_uitest.cc b/chrome/test/perf/kraken_benchmark_uitest.cc new file mode 100644 index 0000000..ac59eb9 --- /dev/null +++ b/chrome/test/perf/kraken_benchmark_uitest.cc @@ -0,0 +1,121 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/string_util.h" +#include "base/test/test_timeouts.h" +#include "base/utf_string_conversions.h" +#include "base/values.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/perf/perf_test.h" +#include "chrome/test/ui/javascript_test_util.h" +#include "chrome/test/ui/ui_perf_test.h" +#include "googleurl/src/gurl.h" +#include "net/base/net_util.h" + +namespace { + +const char kRunKraken[] = "run-kraken-benchmark"; + +class KrakenBenchmarkTest : public UIPerfTest { + public: + typedef std::map<std::string, std::string> ResultsMap; + + KrakenBenchmarkTest() : reference_(false) { + dom_automation_enabled_ = true; + show_window_ = true; + } + + void RunTest() { + FilePath test_path; + PathService::Get(chrome::DIR_TEST_DATA, &test_path); + test_path = test_path.AppendASCII("third_party") + .AppendASCII("kraken") + .AppendASCII("hosted") + .AppendASCII("kraken-1.1") + .Append(FILE_PATH_LITERAL("driver.html")); + GURL test_url(net::FilePathToFileURL(test_path)); + + scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url)); + + // Wait for the test to finish. + ASSERT_TRUE(WaitUntilTestCompletes(tab.get(), test_url)); + + PrintResults(tab.get()); + } + + protected: + bool reference_; // True if this is a reference build. + + private: + bool WaitUntilTestCompletes(TabProxy* tab, const GURL& test_url) { + return WaitUntilCookieValue(tab, test_url, "__done", + TestTimeouts::large_test_timeout_ms(), "1"); + } + + bool GetResults(TabProxy* tab, ResultsMap* results) { + std::wstring json_wide; + bool succeeded = tab->ExecuteAndExtractString(L"", + L"window.domAutomationController.send(" + L" automation.getResults());", + &json_wide); + + EXPECT_TRUE(succeeded); + if (!succeeded) + return false; + + std::string json = WideToUTF8(json_wide); + return JsonDictionaryToMap(json, results); + } + + void PrintResults(TabProxy* tab) { + ResultsMap results; + ASSERT_TRUE(GetResults(tab, &results)); + + std::string trace_name = reference_ ? "score_ref" : "score"; + perf_test::PrintResult("score", "", trace_name, results["score"], "ms", + true); + + ResultsMap::const_iterator it = results.begin(); + for (; it != results.end(); ++it) { + if (it->first == "score") + continue; + perf_test::PrintResult(it->first, "", trace_name, it->second, "ms", + false); + } + } + + DISALLOW_COPY_AND_ASSIGN(KrakenBenchmarkTest); +}; + +class KrakenBenchmarkReferenceTest : public KrakenBenchmarkTest { + public: + KrakenBenchmarkReferenceTest() : KrakenBenchmarkTest() { + reference_ = true; + } + + void SetUp() { + UseReferenceBuild(); + KrakenBenchmarkTest::SetUp(); + } +}; + +TEST_F(KrakenBenchmarkTest, Perf) { + if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunKraken)) + return; + + RunTest(); +} + +TEST_F(KrakenBenchmarkReferenceTest, Perf) { + if (!CommandLine::ForCurrentProcess()->HasSwitch(kRunKraken)) + return; + + RunTest(); +} + +} // namespace diff --git a/chrome/test/perf/kraken_benchmark_uitest.js b/chrome/test/perf/kraken_benchmark_uitest.js new file mode 100644 index 0000000..36511b0 --- /dev/null +++ b/chrome/test/perf/kraken_benchmark_uitest.js @@ -0,0 +1,22 @@ +/* + Copyright (c) 2012 The Chromium Authors. All rights reserved. + Use of this source code is governed by a BSD-style license that can be + found in the LICENSE file. +*/ + +var automation = { + setDone: function() { + document.cookie = '__done=1; path=/'; + }, + + getResults: function() { + results = {'score': String(mean)}; + for (category in categoryMeans) { + results[category] = String(categoryMeans[category]); + for (test in testMeansByCategory[category]) { + results[test] = String(testMeansByCategory[category][test]); + } + } + return JSON.stringify(results); + } +}; |