| 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 "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/password_manager/password_store.h" | 7 #include "chrome/browser/password_manager/password_store.h" |
| 8 #include "chrome/browser/sync/profile_sync_service_harness.h" | 8 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 9 #include "chrome/test/live_sync/live_passwords_sync_test.h" | 9 #include "chrome/test/live_sync/live_passwords_sync_test.h" |
| 10 #include "chrome/test/live_sync/performance/sync_timing_helper.h" | 10 #include "chrome/test/live_sync/performance/sync_timing_helper.h" |
| 11 | 11 |
| 12 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all | |
| 13 // datatypes into a performance test base class, once it is possible to do so. | |
| 14 static const int kNumPasswords = 150; | 12 static const int kNumPasswords = 150; |
| 15 static const int kNumBenchmarkPoints = 18; | |
| 16 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, | |
| 17 150, 175, 200, 225, 250, 300, 350, 400, | |
| 18 500}; | |
| 19 | 13 |
| 20 class PasswordsSyncPerfTest : public TwoClientLivePasswordsSyncTest { | 14 class PasswordsSyncPerfTest : public TwoClientLivePasswordsSyncTest { |
| 21 public: | 15 public: |
| 22 PasswordsSyncPerfTest() : password_number_(0) {} | 16 PasswordsSyncPerfTest() : password_number_(0) {} |
| 23 | 17 |
| 24 // Adds |num_logins| new unique passwords to |profile|. | 18 // Adds |num_logins| new unique passwords to |profile|. |
| 25 void AddLogins(int profile, int num_logins); | 19 void AddLogins(int profile, int num_logins); |
| 26 | 20 |
| 27 // Updates the password for all logins for |profile|. | 21 // Updates the password for all logins for |profile|. |
| 28 void UpdateLogins(int profile); | 22 void UpdateLogins(int profile); |
| 29 | 23 |
| 30 // Removes all logins for |profile|. | 24 // Removes all logins for |profile|. |
| 31 void RemoveLogins(int profile); | 25 void RemoveLogins(int profile); |
| 32 | 26 |
| 33 // Removes all logins for all profiles. Called between benchmark iterations. | |
| 34 void Cleanup(); | |
| 35 | |
| 36 private: | 27 private: |
| 37 // Returns a new unique login. | 28 // Returns a new unique login. |
| 38 webkit_glue::PasswordForm NextLogin(); | 29 webkit_glue::PasswordForm NextLogin(); |
| 39 | 30 |
| 40 // Returns a new unique password value. | 31 // Returns a new unique password value. |
| 41 std::string NextPassword(); | 32 std::string NextPassword(); |
| 42 | 33 |
| 43 int password_number_; | 34 int password_number_; |
| 44 DISALLOW_COPY_AND_ASSIGN(PasswordsSyncPerfTest); | 35 DISALLOW_COPY_AND_ASSIGN(PasswordsSyncPerfTest); |
| 45 }; | 36 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 it != logins.end(); ++it) { | 48 it != logins.end(); ++it) { |
| 58 (*it).password_value = ASCIIToUTF16(NextPassword()); | 49 (*it).password_value = ASCIIToUTF16(NextPassword()); |
| 59 UpdateLogin(GetPasswordStore(profile), (*it)); | 50 UpdateLogin(GetPasswordStore(profile), (*it)); |
| 60 } | 51 } |
| 61 } | 52 } |
| 62 | 53 |
| 63 void PasswordsSyncPerfTest::RemoveLogins(int profile) { | 54 void PasswordsSyncPerfTest::RemoveLogins(int profile) { |
| 64 LivePasswordsSyncTest::RemoveLogins(GetPasswordStore(profile)); | 55 LivePasswordsSyncTest::RemoveLogins(GetPasswordStore(profile)); |
| 65 } | 56 } |
| 66 | 57 |
| 67 void PasswordsSyncPerfTest::Cleanup() { | |
| 68 for (int i = 0; i < num_clients(); ++i) { | |
| 69 RemoveLogins(i); | |
| 70 } | |
| 71 ASSERT_TRUE(AwaitQuiescence()); | |
| 72 ASSERT_EQ(0, GetPasswordCount(0)); | |
| 73 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | |
| 74 } | |
| 75 | |
| 76 webkit_glue::PasswordForm PasswordsSyncPerfTest::NextLogin() { | 58 webkit_glue::PasswordForm PasswordsSyncPerfTest::NextLogin() { |
| 77 return CreateTestPasswordForm(password_number_++); | 59 return CreateTestPasswordForm(password_number_++); |
| 78 } | 60 } |
| 79 | 61 |
| 80 std::string PasswordsSyncPerfTest::NextPassword() { | 62 std::string PasswordsSyncPerfTest::NextPassword() { |
| 81 return base::StringPrintf("password%d", password_number_++); | 63 return base::StringPrintf("password%d", password_number_++); |
| 82 } | 64 } |
| 83 | 65 |
| 84 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, P0) { | 66 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, P0) { |
| 85 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 67 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 96 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 78 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 97 ASSERT_EQ(kNumPasswords, GetPasswordCount(1)); | 79 ASSERT_EQ(kNumPasswords, GetPasswordCount(1)); |
| 98 SyncTimingHelper::PrintResult("passwords", "update_passwords", dt); | 80 SyncTimingHelper::PrintResult("passwords", "update_passwords", dt); |
| 99 | 81 |
| 100 // TCM ID - 7557852 | 82 // TCM ID - 7557852 |
| 101 RemoveLogins(0); | 83 RemoveLogins(0); |
| 102 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 84 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 103 ASSERT_EQ(0, GetPasswordCount(1)); | 85 ASSERT_EQ(0, GetPasswordCount(1)); |
| 104 SyncTimingHelper::PrintResult("passwords", "delete_passwords", dt); | 86 SyncTimingHelper::PrintResult("passwords", "delete_passwords", dt); |
| 105 } | 87 } |
| 106 | |
| 107 IN_PROC_BROWSER_TEST_F(PasswordsSyncPerfTest, DISABLED_Benchmark) { | |
| 108 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | |
| 109 | |
| 110 for (int i = 0; i < kNumBenchmarkPoints; ++i) { | |
| 111 int num_passwords = kBenchmarkPoints[i]; | |
| 112 AddLogins(0, num_passwords); | |
| 113 base::TimeDelta dt_add = | |
| 114 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | |
| 115 ASSERT_EQ(num_passwords, GetPasswordCount(0)); | |
| 116 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | |
| 117 VLOG(0) << std::endl << "Add: " << num_passwords << " " | |
| 118 << dt_add.InSecondsF(); | |
| 119 | |
| 120 UpdateLogins(0); | |
| 121 base::TimeDelta dt_update = | |
| 122 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | |
| 123 ASSERT_EQ(num_passwords, GetPasswordCount(0)); | |
| 124 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | |
| 125 VLOG(0) << std::endl << "Update: " << num_passwords << " " | |
| 126 << dt_update.InSecondsF(); | |
| 127 | |
| 128 RemoveLogins(0); | |
| 129 base::TimeDelta dt_delete = | |
| 130 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | |
| 131 ASSERT_EQ(0, GetPasswordCount(0)); | |
| 132 ASSERT_TRUE(AllProfilesContainSamePasswordForms()); | |
| 133 VLOG(0) << std::endl << "Delete: " << num_passwords << " " | |
| 134 << dt_delete.InSecondsF(); | |
| 135 | |
| 136 Cleanup(); | |
| 137 } | |
| 138 } | |
| OLD | NEW |