| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 8 #include "base/string_util.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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 static const int kNumCycles = 5; | 32 static const int kNumCycles = 5; |
| 33 | 33 |
| 34 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], | 34 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], |
| 35 bool important) { | 35 bool important) { |
| 36 std::string times; | 36 std::string times; |
| 37 for (int i = 0; i < kNumCycles; ++i) | 37 for (int i = 0; i < kNumCycles; ++i) |
| 38 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); | 38 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); |
| 39 PrintResultList("new_tab", "", label, times, "ms", important); | 39 PrintResultList("new_tab", "", label, times, "ms", important); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void InitProfile(UITest::ProfileType profile_type) { | 42 void InitProfile(ProxyLauncher::ProfileType profile_type) { |
| 43 profile_type_ = profile_type; | 43 profile_type_ = profile_type; |
| 44 | 44 |
| 45 // Install the location of the test profile file. | 45 // Install the location of the test profile file. |
| 46 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 46 set_template_user_data(UITest::ComputeTypicalUserDataSource( |
| 47 profile_type)); | 47 profile_type)); |
| 48 | 48 |
| 49 // Disable the first run notification because it has an animation which | 49 // Disable the first run notification because it has an animation which |
| 50 // masks any real performance regressions. | 50 // masks any real performance regressions. |
| 51 launch_arguments_.AppendSwitch(switches::kDisableNewTabFirstRun); | 51 launch_arguments_.AppendSwitch(switches::kDisableNewTabFirstRun); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // 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. |
| 55 // |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 |
| 56 // we should report cold timings. | 56 // we should report cold timings. |
| 57 void RunStartupTest(const char* label, bool want_warm, bool important, | 57 void RunStartupTest(const char* label, bool want_warm, bool important, |
| 58 UITest::ProfileType profile_type) { | 58 ProxyLauncher::ProfileType profile_type) { |
| 59 InitProfile(profile_type); | 59 InitProfile(profile_type); |
| 60 | 60 |
| 61 TimeDelta timings[kNumCycles]; | 61 TimeDelta timings[kNumCycles]; |
| 62 for (int i = 0; i < kNumCycles; ++i) { | 62 for (int i = 0; i < kNumCycles; ++i) { |
| 63 UITest::SetUp(); | 63 UITest::SetUp(); |
| 64 | 64 |
| 65 // 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 |
| 66 // first (the first is about:blank). | 66 // first (the first is about:blank). |
| 67 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 67 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 68 ASSERT_TRUE(window.get()); | 68 ASSERT_TRUE(window.get()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 timings[i] = TimeDelta::FromMilliseconds(load_time); | 96 timings[i] = TimeDelta::FromMilliseconds(load_time); |
| 97 | 97 |
| 98 window = NULL; | 98 window = NULL; |
| 99 UITest::TearDown(); | 99 UITest::TearDown(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 PrintTimings(label, timings, important); | 102 PrintTimings(label, timings, important); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void RunNewTabTimingTest() { | 105 void RunNewTabTimingTest() { |
| 106 InitProfile(UITest::DEFAULT_THEME); | 106 InitProfile(ProxyLauncher::DEFAULT_THEME); |
| 107 | 107 |
| 108 TimeDelta scriptstart_times[kNumCycles]; | 108 TimeDelta scriptstart_times[kNumCycles]; |
| 109 TimeDelta domcontentloaded_times[kNumCycles]; | 109 TimeDelta domcontentloaded_times[kNumCycles]; |
| 110 TimeDelta onload_times[kNumCycles]; | 110 TimeDelta onload_times[kNumCycles]; |
| 111 | 111 |
| 112 for (int i = 0; i < kNumCycles; ++i) { | 112 for (int i = 0; i < kNumCycles; ++i) { |
| 113 UITest::SetUp(); | 113 UITest::SetUp(); |
| 114 | 114 |
| 115 // 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 |
| 116 // first (the first is about:blank). | 116 // first (the first is about:blank). |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 PrintTimings("script_start", scriptstart_times, false /* important */); | 156 PrintTimings("script_start", scriptstart_times, false /* important */); |
| 157 PrintTimings("domcontent_loaded", domcontentloaded_times, | 157 PrintTimings("domcontent_loaded", domcontentloaded_times, |
| 158 false /* important */); | 158 false /* important */); |
| 159 PrintTimings("onload", onload_times, false /* important */); | 159 PrintTimings("onload", onload_times, false /* important */); |
| 160 } | 160 } |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 TEST_F(NewTabUIStartupTest, PerfRefCold) { | 163 TEST_F(NewTabUIStartupTest, PerfRefCold) { |
| 164 UseReferenceBuild(); | 164 UseReferenceBuild(); |
| 165 RunStartupTest("tab_cold_ref", false /* cold */, true /* important */, | 165 RunStartupTest("tab_cold_ref", false /* cold */, true /* important */, |
| 166 UITest::DEFAULT_THEME); | 166 ProxyLauncher::DEFAULT_THEME); |
| 167 } | 167 } |
| 168 | 168 |
| 169 TEST_F(NewTabUIStartupTest, PerfCold) { | 169 TEST_F(NewTabUIStartupTest, PerfCold) { |
| 170 RunStartupTest("tab_cold", false /* cold */, true /* important */, | 170 RunStartupTest("tab_cold", false /* cold */, true /* important */, |
| 171 UITest::DEFAULT_THEME); | 171 ProxyLauncher::DEFAULT_THEME); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_F(NewTabUIStartupTest, PerfRefWarm) { | 174 TEST_F(NewTabUIStartupTest, PerfRefWarm) { |
| 175 UseReferenceBuild(); | 175 UseReferenceBuild(); |
| 176 RunStartupTest("tab_warm_ref", true /* warm */, true /* not important */, | 176 RunStartupTest("tab_warm_ref", true /* warm */, true /* not important */, |
| 177 UITest::DEFAULT_THEME); | 177 ProxyLauncher::DEFAULT_THEME); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST_F(NewTabUIStartupTest, PerfWarm) { | 180 TEST_F(NewTabUIStartupTest, PerfWarm) { |
| 181 RunStartupTest("tab_warm", true /* warm */, true /* not important */, | 181 RunStartupTest("tab_warm", true /* warm */, true /* not important */, |
| 182 UITest::DEFAULT_THEME); | 182 ProxyLauncher::DEFAULT_THEME); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST_F(NewTabUIStartupTest, ComplexThemeCold) { | 185 TEST_F(NewTabUIStartupTest, ComplexThemeCold) { |
| 186 RunStartupTest("tab_complex_theme_cold", false /* cold */, | 186 RunStartupTest("tab_complex_theme_cold", false /* cold */, |
| 187 false /* not important */, | 187 false /* not important */, |
| 188 UITest::COMPLEX_THEME); | 188 ProxyLauncher::COMPLEX_THEME); |
| 189 } | 189 } |
| 190 | 190 |
| 191 TEST_F(NewTabUIStartupTest, NewTabTimingTestsCold) { | 191 TEST_F(NewTabUIStartupTest, NewTabTimingTestsCold) { |
| 192 RunNewTabTimingTest(); | 192 RunNewTabTimingTest(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 #if defined(OS_LINUX) | 195 #if defined(OS_LINUX) |
| 196 TEST_F(NewTabUIStartupTest, GtkThemeCold) { | 196 TEST_F(NewTabUIStartupTest, GtkThemeCold) { |
| 197 RunStartupTest("tab_gtk_theme_cold", false /* cold */, | 197 RunStartupTest("tab_gtk_theme_cold", false /* cold */, |
| 198 false /* not important */, | 198 false /* not important */, |
| 199 UITest::NATIVE_THEME); | 199 ProxyLauncher::NATIVE_THEME); |
| 200 } | 200 } |
| 201 | 201 |
| 202 TEST_F(NewTabUIStartupTest, NativeFrameCold) { | 202 TEST_F(NewTabUIStartupTest, NativeFrameCold) { |
| 203 RunStartupTest("tab_custom_frame_cold", false /* cold */, | 203 RunStartupTest("tab_custom_frame_cold", false /* cold */, |
| 204 false /* not important */, | 204 false /* not important */, |
| 205 UITest::CUSTOM_FRAME); | 205 ProxyLauncher::CUSTOM_FRAME); |
| 206 } | 206 } |
| 207 | 207 |
| 208 TEST_F(NewTabUIStartupTest, NativeFrameGtkThemeCold) { | 208 TEST_F(NewTabUIStartupTest, NativeFrameGtkThemeCold) { |
| 209 RunStartupTest("tab_custom_frame_gtk_theme_cold", false /* cold */, | 209 RunStartupTest("tab_custom_frame_gtk_theme_cold", false /* cold */, |
| 210 false /* not important */, | 210 false /* not important */, |
| 211 UITest::CUSTOM_FRAME_NATIVE_THEME); | 211 ProxyLauncher::CUSTOM_FRAME_NATIVE_THEME); |
| 212 } | 212 } |
| 213 #endif | 213 #endif |
| 214 | 214 |
| 215 } // namespace | 215 } // namespace |
| OLD | NEW |