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