| 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 "base/stringprintf.h" | 5 #include "base/stringprintf.h" |
| 6 #include "chrome/browser/autofill/autofill_common_test.h" | 6 #include "chrome/browser/autofill/autofill_common_test.h" |
| 7 #include "chrome/browser/sync/profile_sync_service_harness.h" | 7 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 8 #include "chrome/test/live_sync/live_autofill_sync_test.h" | 8 #include "chrome/test/live_sync/live_autofill_sync_test.h" |
| 9 #include "chrome/test/live_sync/performance/sync_timing_helper.h" | 9 #include "chrome/test/live_sync/performance/sync_timing_helper.h" |
| 10 | 10 |
| 11 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all |
| 12 // datatypes into a performance test base class, once it is possible to do so. |
| 11 static const int kNumProfiles = 150; | 13 static const int kNumProfiles = 150; |
| 12 | |
| 13 // TODO(braffert): Consider the range / resolution of these test points. | |
| 14 static const int kNumBenchmarkPoints = 18; | 14 static const int kNumBenchmarkPoints = 18; |
| 15 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, | 15 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, |
| 16 150, 175, 200, 225, 250, 300, 350, 400, | 16 150, 175, 200, 225, 250, 300, 350, 400, |
| 17 500}; | 17 500}; |
| 18 | 18 |
| 19 // TODO(braffert): Move this class into its own .h/.cc files. What should the | |
| 20 // class files be named as opposed to the file containing the tests themselves? | |
| 21 class AutofillSyncPerfTest | 19 class AutofillSyncPerfTest |
| 22 : public TwoClientLiveAutofillSyncTest { | 20 : public TwoClientLiveAutofillSyncTest { |
| 23 public: | 21 public: |
| 24 AutofillSyncPerfTest() : guid_number_(0), name_number_(0) {} | 22 AutofillSyncPerfTest() : guid_number_(0), name_number_(0) {} |
| 25 | 23 |
| 26 // Adds |num_profiles| new autofill profiles to the sync profile |profile|. | 24 // Adds |num_profiles| new autofill profiles to the sync profile |profile|. |
| 27 void AddProfiles(int profile, int num_profiles); | 25 void AddProfiles(int profile, int num_profiles); |
| 28 | 26 |
| 29 // Updates all autofill profiles for the sync profile |profile|. | 27 // Updates all autofill profiles for the sync profile |profile|. |
| 30 void UpdateProfiles(int profile); | 28 void UpdateProfiles(int profile); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // TCM ID - 7557873. | 118 // TCM ID - 7557873. |
| 121 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Add) { | 119 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Add) { |
| 122 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 120 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 123 | 121 |
| 124 AddProfiles(0, kNumProfiles); | 122 AddProfiles(0, kNumProfiles); |
| 125 base::TimeDelta dt = | 123 base::TimeDelta dt = |
| 126 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 124 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 127 ASSERT_EQ(kNumProfiles, GetProfileCount(0)); | 125 ASSERT_EQ(kNumProfiles, GetProfileCount(0)); |
| 128 ASSERT_TRUE(AllProfilesMatch()); | 126 ASSERT_TRUE(AllProfilesMatch()); |
| 129 | 127 |
| 130 // TODO(braffert): Compare timings against some target value. | 128 SyncTimingHelper::PrintResult("autofill", "add", dt); |
| 131 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 132 } | 129 } |
| 133 | 130 |
| 134 // TCM ID - 7549835. | 131 // TCM ID - 7549835. |
| 135 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Update) { | 132 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Update) { |
| 136 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 133 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 137 | 134 |
| 138 AddProfiles(0, kNumProfiles); | 135 AddProfiles(0, kNumProfiles); |
| 139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 136 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 140 | 137 |
| 141 UpdateProfiles(0); | 138 UpdateProfiles(0); |
| 142 base::TimeDelta dt = | 139 base::TimeDelta dt = |
| 143 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 140 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 144 ASSERT_EQ(kNumProfiles, GetProfileCount(0)); | 141 ASSERT_EQ(kNumProfiles, GetProfileCount(0)); |
| 145 ASSERT_TRUE(AllProfilesMatch()); | 142 ASSERT_TRUE(AllProfilesMatch()); |
| 146 | 143 |
| 147 // TODO(braffert): Compare timings against some target value. | 144 SyncTimingHelper::PrintResult("autofill", "update", dt); |
| 148 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 149 } | 145 } |
| 150 | 146 |
| 151 // TCM ID - 7553678. | 147 // TCM ID - 7553678. |
| 152 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Delete) { | 148 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Delete) { |
| 153 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 149 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 154 | 150 |
| 155 AddProfiles(0, kNumProfiles); | 151 AddProfiles(0, kNumProfiles); |
| 156 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 152 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 157 | 153 |
| 158 RemoveProfiles(0); | 154 RemoveProfiles(0); |
| 159 base::TimeDelta dt = | 155 base::TimeDelta dt = |
| 160 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 156 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 161 ASSERT_EQ(0, GetProfileCount(0)); | 157 ASSERT_EQ(0, GetProfileCount(0)); |
| 162 ASSERT_TRUE(AllProfilesMatch()); | 158 ASSERT_TRUE(AllProfilesMatch()); |
| 163 | 159 |
| 164 // TODO(braffert): Compare timings against some target value. | 160 SyncTimingHelper::PrintResult("autofill", "delete", dt); |
| 165 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 166 } | 161 } |
| 167 | 162 |
| 168 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) { | 163 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) { |
| 169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 164 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 170 | 165 |
| 171 for (int i = 0; i < kNumBenchmarkPoints; ++i) { | 166 for (int i = 0; i < kNumBenchmarkPoints; ++i) { |
| 172 int num_profiles = kBenchmarkPoints[i]; | 167 int num_profiles = kBenchmarkPoints[i]; |
| 173 AddProfiles(0, num_profiles); | 168 AddProfiles(0, num_profiles); |
| 174 base::TimeDelta dt_add = | 169 base::TimeDelta dt_add = |
| 175 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 170 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 190 base::TimeDelta dt_delete = | 185 base::TimeDelta dt_delete = |
| 191 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 186 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 192 ASSERT_EQ(0, GetProfileCount(0)); | 187 ASSERT_EQ(0, GetProfileCount(0)); |
| 193 ASSERT_TRUE(AllProfilesMatch()); | 188 ASSERT_TRUE(AllProfilesMatch()); |
| 194 VLOG(0) << std::endl << "Delete: " << num_profiles << " " | 189 VLOG(0) << std::endl << "Delete: " << num_profiles << " " |
| 195 << dt_delete.InSecondsF(); | 190 << dt_delete.InSecondsF(); |
| 196 | 191 |
| 197 Cleanup(); | 192 Cleanup(); |
| 198 } | 193 } |
| 199 } | 194 } |
| OLD | NEW |