Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/perftimer.h" | 7 #include "base/perftimer.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/automation/automation_proxy.h" | 13 #include "chrome/test/automation/automation_proxy.h" |
| 14 #include "chrome/test/automation/browser_proxy.h" | 14 #include "chrome/test/automation/browser_proxy.h" |
| 15 #include "chrome/test/automation/window_proxy.h" | 15 #include "chrome/test/automation/window_proxy.h" |
| 16 #include "chrome/test/perf/perf_test.h" | 16 #include "chrome/test/perf/perf_test.h" |
| 17 #include "chrome/test/perf/perf_ui_test_suite.h" | |
| 17 #include "chrome/test/ui/ui_perf_test.h" | 18 #include "chrome/test/ui/ui_perf_test.h" |
| 18 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 | 21 |
| 21 using base::TimeDelta; | 22 using base::TimeDelta; |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 class NewTabUIStartupTest : public UIPerfTest { | 26 class NewTabUIStartupTest : public UIPerfTest { |
| 26 public: | 27 public: |
| 27 NewTabUIStartupTest() { | 28 NewTabUIStartupTest() { |
| 28 show_window_ = true; | 29 show_window_ = true; |
| 29 } | 30 } |
| 30 | 31 |
| 31 virtual void SetUp() {} | 32 virtual void SetUp() {} |
| 32 virtual void TearDown() {} | 33 virtual void TearDown() {} |
| 33 | 34 |
| 34 static const int kNumCycles = 5; | 35 static const int kNumCycles = 5; |
| 35 | 36 |
| 36 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], | 37 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], |
| 37 bool important) { | 38 bool important) { |
| 38 std::string times; | 39 std::string times; |
| 39 for (int i = 0; i < kNumCycles; ++i) | 40 for (int i = 0; i < kNumCycles; ++i) |
| 40 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); | 41 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); |
| 41 perf_test::PrintResultList( | 42 perf_test::PrintResultList( |
| 42 "new_tab", std::string(), label, times, "ms", important); | 43 "new_tab", std::string(), label, times, "ms", important); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void InitProfile(UITestBase::ProfileType profile_type) { | 46 void InitProfile(PerfUITestSuite::ProfileType profile_type) { |
| 46 profile_type_ = profile_type; | 47 profile_type_ = profile_type; |
|
Randy Smith (Not in Mondays)
2013/04/30 21:27:36
It looks like we initialize this and never use it-
| |
| 47 | 48 |
| 48 // Install the location of the test profile file. | 49 // Install the location of the test profile file. |
| 49 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 50 set_template_user_data( |
| 50 profile_type)); | 51 PerfUITestSuite::GetPathForProfileType(profile_type)); |
| 51 } | 52 } |
| 52 | 53 |
| 53 // Run the test, by bringing up a browser and timing the new tab startup. | 54 // Run the test, by bringing up a browser and timing the new tab startup. |
| 54 // |want_warm| is true if we should output warm-disk timings, false if | 55 // |want_warm| is true if we should output warm-disk timings, false if |
| 55 // we should report cold timings. | 56 // we should report cold timings. |
| 56 void RunStartupTest(const char* label, bool want_warm, bool important, | 57 void RunStartupTest(const char* label, bool want_warm, bool important, |
| 57 UITestBase::ProfileType profile_type) { | 58 PerfUITestSuite::ProfileType profile_type) { |
| 58 InitProfile(profile_type); | 59 InitProfile(profile_type); |
| 59 | 60 |
| 60 TimeDelta timings[kNumCycles]; | 61 TimeDelta timings[kNumCycles]; |
| 61 for (int i = 0; i < kNumCycles; ++i) { | 62 for (int i = 0; i < kNumCycles; ++i) { |
| 62 UITest::SetUp(); | 63 UITest::SetUp(); |
| 63 | 64 |
| 64 // Switch to the "new tab" tab, which should be any new tab after the | 65 // Switch to the "new tab" tab, which should be any new tab after the |
| 65 // first (the first is about:blank). | 66 // first (the first is about:blank). |
| 66 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 67 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 67 ASSERT_TRUE(window.get()); | 68 ASSERT_TRUE(window.get()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 95 timings[i] = TimeDelta::FromMilliseconds(load_time); | 96 timings[i] = TimeDelta::FromMilliseconds(load_time); |
| 96 | 97 |
| 97 window = NULL; | 98 window = NULL; |
| 98 UITest::TearDown(); | 99 UITest::TearDown(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 PrintTimings(label, timings, important); | 102 PrintTimings(label, timings, important); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void RunNewTabTimingTest() { | 105 void RunNewTabTimingTest() { |
| 105 InitProfile(UITestBase::DEFAULT_THEME); | 106 InitProfile(PerfUITestSuite::DEFAULT_THEME); |
| 106 | 107 |
| 107 TimeDelta scriptstart_times[kNumCycles]; | 108 TimeDelta scriptstart_times[kNumCycles]; |
| 108 TimeDelta domcontentloaded_times[kNumCycles]; | 109 TimeDelta domcontentloaded_times[kNumCycles]; |
| 109 TimeDelta onload_times[kNumCycles]; | 110 TimeDelta onload_times[kNumCycles]; |
| 110 | 111 |
| 111 for (int i = 0; i < kNumCycles; ++i) { | 112 for (int i = 0; i < kNumCycles; ++i) { |
| 112 UITest::SetUp(); | 113 UITest::SetUp(); |
| 113 | 114 |
| 114 // Switch to the "new tab" tab, which should be any new tab after the | 115 // Switch to the "new tab" tab, which should be any new tab after the |
| 115 // first (the first is about:blank). | 116 // first (the first is about:blank). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 151 |
| 151 window = NULL; | 152 window = NULL; |
| 152 UITest::TearDown(); | 153 UITest::TearDown(); |
| 153 } | 154 } |
| 154 | 155 |
| 155 PrintTimings("script_start", scriptstart_times, false /* important */); | 156 PrintTimings("script_start", scriptstart_times, false /* important */); |
| 156 PrintTimings("domcontent_loaded", domcontentloaded_times, | 157 PrintTimings("domcontent_loaded", domcontentloaded_times, |
| 157 false /* important */); | 158 false /* important */); |
| 158 PrintTimings("onload", onload_times, false /* important */); | 159 PrintTimings("onload", onload_times, false /* important */); |
| 159 } | 160 } |
| 161 | |
| 162 private: | |
| 163 // Are we using a profile with a complex theme? | |
| 164 PerfUITestSuite::ProfileType profile_type_; | |
| 160 }; | 165 }; |
| 161 | 166 |
| 162 // FLAKY: http://crbug.com/69940 | 167 // FLAKY: http://crbug.com/69940 |
| 163 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefCold) { | 168 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefCold) { |
| 164 UseReferenceBuild(); | 169 UseReferenceBuild(); |
| 165 RunStartupTest("tab_cold_ref", false /* cold */, true /* important */, | 170 RunStartupTest("tab_cold_ref", false /* cold */, true /* important */, |
| 166 UITestBase::DEFAULT_THEME); | 171 PerfUITestSuite::DEFAULT_THEME); |
| 167 } | 172 } |
| 168 | 173 |
| 169 // FLAKY: http://crbug.com/69940 | 174 // FLAKY: http://crbug.com/69940 |
| 170 TEST_F(NewTabUIStartupTest, DISABLED_PerfCold) { | 175 TEST_F(NewTabUIStartupTest, DISABLED_PerfCold) { |
| 171 RunStartupTest("tab_cold", false /* cold */, true /* important */, | 176 RunStartupTest("tab_cold", false /* cold */, true /* important */, |
| 172 UITestBase::DEFAULT_THEME); | 177 PerfUITestSuite::DEFAULT_THEME); |
| 173 } | 178 } |
| 174 | 179 |
| 175 // FLAKY: http://crbug.com/69940 | 180 // FLAKY: http://crbug.com/69940 |
| 176 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefWarm) { | 181 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefWarm) { |
| 177 UseReferenceBuild(); | 182 UseReferenceBuild(); |
| 178 RunStartupTest("tab_warm_ref", true /* warm */, true /* not important */, | 183 RunStartupTest("tab_warm_ref", true /* warm */, true /* not important */, |
| 179 UITestBase::DEFAULT_THEME); | 184 PerfUITestSuite::DEFAULT_THEME); |
| 180 } | 185 } |
| 181 | 186 |
| 182 // FLAKY: http://crbug.com/69940 | 187 // FLAKY: http://crbug.com/69940 |
| 183 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { | 188 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { |
| 184 RunStartupTest("tab_warm", true /* warm */, true /* not important */, | 189 RunStartupTest("tab_warm", true /* warm */, true /* not important */, |
| 185 UITestBase::DEFAULT_THEME); | 190 PerfUITestSuite::DEFAULT_THEME); |
| 186 } | 191 } |
| 187 | 192 |
| 188 // FLAKY: http://crbug.com/69940 | 193 // FLAKY: http://crbug.com/69940 |
| 189 TEST_F(NewTabUIStartupTest, DISABLED_ComplexThemeCold) { | 194 TEST_F(NewTabUIStartupTest, DISABLED_ComplexThemeCold) { |
| 190 RunStartupTest("tab_complex_theme_cold", false /* cold */, | 195 RunStartupTest("tab_complex_theme_cold", false /* cold */, |
| 191 false /* not important */, | 196 false /* not important */, |
| 192 UITestBase::COMPLEX_THEME); | 197 PerfUITestSuite::COMPLEX_THEME); |
| 193 } | 198 } |
| 194 | 199 |
| 195 // FLAKY: http://crbug.com/69940 | 200 // FLAKY: http://crbug.com/69940 |
| 196 TEST_F(NewTabUIStartupTest, DISABLED_NewTabTimingTestsCold) { | 201 TEST_F(NewTabUIStartupTest, DISABLED_NewTabTimingTestsCold) { |
| 197 RunNewTabTimingTest(); | 202 RunNewTabTimingTest(); |
| 198 } | 203 } |
| 199 | 204 |
| 200 } // namespace | 205 } // namespace |
| OLD | NEW |