| 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/password_manager/password_store.h" | 6 #include "chrome/browser/password_manager/password_store.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_passwords_sync_test.h" | 8 #include "chrome/test/live_sync/live_passwords_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 kNumPasswords = 150; | 13 static const int kNumPasswords = 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 PasswordsSyncPerfTest | 19 class PasswordsSyncPerfTest |
| 22 : public TwoClientLivePasswordsSyncTest { | 20 : public TwoClientLivePasswordsSyncTest { |
| 23 public: | 21 public: |
| 24 PasswordsSyncPerfTest() : password_number_(0) {} | 22 PasswordsSyncPerfTest() : password_number_(0) {} |
| 25 | 23 |
| 26 // Adds |num_logins| new unique passwords to |profile|. | 24 // Adds |num_logins| new unique passwords to |profile|. |
| 27 void AddLogins(int profile, int num_logins); | 25 void AddLogins(int profile, int num_logins); |
| 28 | 26 |
| 29 // Updates the password for all logins for |profile|. | 27 // Updates the password for all logins for |profile|. |
| 30 void UpdateLogins(int profile); | 28 void UpdateLogins(int profile); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // TCM ID - 7567749. | 84 // TCM ID - 7567749. |
| 87 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, Add) { | 85 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, Add) { |
| 88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 86 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 89 | 87 |
| 90 AddLogins(0, kNumPasswords); | 88 AddLogins(0, kNumPasswords); |
| 91 base::TimeDelta dt = | 89 base::TimeDelta dt = |
| 92 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 90 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 93 ASSERT_EQ(kNumPasswords, GetPasswordCount(0)); | 91 ASSERT_EQ(kNumPasswords, GetPasswordCount(0)); |
| 94 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | 92 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); |
| 95 | 93 |
| 96 // TODO(braffert): Compare timings against some target value. | 94 SyncTimingHelper::PrintResult("passwords", "add", dt); |
| 97 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 98 } | 95 } |
| 99 | 96 |
| 100 // TCM ID - 7365093. | 97 // TCM ID - 7365093. |
| 101 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, Update) { | 98 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, Update) { |
| 102 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 103 | 100 |
| 104 AddLogins(0, kNumPasswords); | 101 AddLogins(0, kNumPasswords); |
| 105 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 102 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 106 | 103 |
| 107 UpdateLogins(0); | 104 UpdateLogins(0); |
| 108 base::TimeDelta dt = | 105 base::TimeDelta dt = |
| 109 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 106 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 110 ASSERT_EQ(kNumPasswords, GetPasswordCount(0)); | 107 ASSERT_EQ(kNumPasswords, GetPasswordCount(0)); |
| 111 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | 108 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); |
| 112 | 109 |
| 113 // TODO(braffert): Compare timings against some target value. | 110 SyncTimingHelper::PrintResult("passwords", "update", dt); |
| 114 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 115 } | 111 } |
| 116 | 112 |
| 117 // TCM ID - 7557852. | 113 // TCM ID - 7557852. |
| 118 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, Delete) { | 114 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, Delete) { |
| 119 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 115 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 120 | 116 |
| 121 AddLogins(0, kNumPasswords); | 117 AddLogins(0, kNumPasswords); |
| 122 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 118 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 123 | 119 |
| 124 RemoveLogins(0); | 120 RemoveLogins(0); |
| 125 base::TimeDelta dt = | 121 base::TimeDelta dt = |
| 126 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 122 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 127 ASSERT_EQ(0, GetPasswordCount(0)); | 123 ASSERT_EQ(0, GetPasswordCount(0)); |
| 128 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | 124 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); |
| 129 | 125 |
| 130 // TODO(braffert): Compare timings against some target value. | 126 SyncTimingHelper::PrintResult("passwords", "delete", dt); |
| 131 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 132 } | 127 } |
| 133 | 128 |
| 134 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, DISABLED_Benchmark) { | 129 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, DISABLED_Benchmark) { |
| 135 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 130 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 136 | 131 |
| 137 for (int i = 0; i < kNumBenchmarkPoints; ++i) { | 132 for (int i = 0; i < kNumBenchmarkPoints; ++i) { |
| 138 int num_passwords = kBenchmarkPoints[i]; | 133 int num_passwords = kBenchmarkPoints[i]; |
| 139 AddLogins(0, num_passwords); | 134 AddLogins(0, num_passwords); |
| 140 base::TimeDelta dt_add = | 135 base::TimeDelta dt_add = |
| 141 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 136 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 156 base::TimeDelta dt_delete = | 151 base::TimeDelta dt_delete = |
| 157 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 152 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 158 ASSERT_EQ(0, GetPasswordCount(0)); | 153 ASSERT_EQ(0, GetPasswordCount(0)); |
| 159 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | 154 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); |
| 160 VLOG(0) << std::endl << "Delete: " << num_passwords << " " | 155 VLOG(0) << std::endl << "Delete: " << num_passwords << " " |
| 161 << dt_delete.InSecondsF(); | 156 << dt_delete.InSecondsF(); |
| 162 | 157 |
| 163 Cleanup(); | 158 Cleanup(); |
| 164 } | 159 } |
| 165 } | 160 } |
| OLD | NEW |