Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/test/live_sync/performance/autofill_sync_perf_test.cc

Issue 7461109: Allow sync integration tests to operate on multiple datatypes: Typed Urls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback; rebase Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/autofill/autofill_common_test.h" 7 #include "chrome/browser/autofill/autofill_common_test.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/autofill_helper.h" 9 #include "chrome/test/live_sync/autofill_helper.h"
10 #include "chrome/test/live_sync/live_sync_test.h" 10 #include "chrome/test/live_sync/live_sync_test.h"
11 #include "chrome/test/live_sync/performance/sync_timing_helper.h" 11 #include "chrome/test/live_sync/performance/sync_timing_helper.h"
12 12
13 using autofill_helper::AllProfilesMatch;
14 using autofill_helper::GetAllProfiles;
15 using autofill_helper::GetProfileCount;
16 using autofill_helper::SetProfiles;
17
13 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all 18 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all
14 // datatypes into a performance test base class, once it is possible to do so. 19 // datatypes into a performance test base class, once it is possible to do so.
15 static const int kNumProfiles = 150; 20 static const int kNumProfiles = 150;
16 static const int kNumBenchmarkPoints = 18; 21 static const int kNumBenchmarkPoints = 18;
17 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, 22 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
18 150, 175, 200, 225, 250, 300, 350, 400, 23 150, 175, 200, 225, 250, 300, 350, 400,
19 500}; 24 500};
20 25
21 class AutofillSyncPerfTest : public LiveSyncTest { 26 class AutofillSyncPerfTest : public LiveSyncTest {
22 public: 27 public:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Returns a unique name based on the input integer |n|. 59 // Returns a unique name based on the input integer |n|.
55 const std::string IntToName(int n); 60 const std::string IntToName(int n);
56 61
57 int guid_number_; 62 int guid_number_;
58 int name_number_; 63 int name_number_;
59 DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest); 64 DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest);
60 }; 65 };
61 66
62 void AutofillSyncPerfTest::AddProfiles(int profile, int num_profiles) { 67 void AutofillSyncPerfTest::AddProfiles(int profile, int num_profiles) {
63 const std::vector<AutofillProfile*>& all_profiles = 68 const std::vector<AutofillProfile*>& all_profiles =
64 AutofillHelper::GetAllProfiles(profile); 69 GetAllProfiles(profile);
65 std::vector<AutofillProfile> autofill_profiles; 70 std::vector<AutofillProfile> autofill_profiles;
66 for (size_t i = 0; i < all_profiles.size(); ++i) { 71 for (size_t i = 0; i < all_profiles.size(); ++i) {
67 autofill_profiles.push_back(*all_profiles[i]); 72 autofill_profiles.push_back(*all_profiles[i]);
68 } 73 }
69 for (int i = 0; i < num_profiles; ++i) { 74 for (int i = 0; i < num_profiles; ++i) {
70 autofill_profiles.push_back(NextAutofillProfile()); 75 autofill_profiles.push_back(NextAutofillProfile());
71 } 76 }
72 AutofillHelper::SetProfiles(profile, &autofill_profiles); 77 SetProfiles(profile, &autofill_profiles);
73 } 78 }
74 79
75 void AutofillSyncPerfTest::UpdateProfiles(int profile) { 80 void AutofillSyncPerfTest::UpdateProfiles(int profile) {
76 const std::vector<AutofillProfile*>& all_profiles = 81 const std::vector<AutofillProfile*>& all_profiles =
77 AutofillHelper::GetAllProfiles(profile); 82 GetAllProfiles(profile);
78 std::vector<AutofillProfile> autofill_profiles; 83 std::vector<AutofillProfile> autofill_profiles;
79 for (size_t i = 0; i < all_profiles.size(); ++i) { 84 for (size_t i = 0; i < all_profiles.size(); ++i) {
80 autofill_profiles.push_back(*all_profiles[i]); 85 autofill_profiles.push_back(*all_profiles[i]);
81 autofill_profiles.back().SetInfo(AutofillFieldType(NAME_FIRST), 86 autofill_profiles.back().SetInfo(AutofillFieldType(NAME_FIRST),
82 UTF8ToUTF16(NextName())); 87 UTF8ToUTF16(NextName()));
83 } 88 }
84 AutofillHelper::SetProfiles(profile, &autofill_profiles); 89 SetProfiles(profile, &autofill_profiles);
85 } 90 }
86 91
87 void AutofillSyncPerfTest::RemoveProfiles(int profile) { 92 void AutofillSyncPerfTest::RemoveProfiles(int profile) {
88 std::vector<AutofillProfile> empty; 93 std::vector<AutofillProfile> empty;
89 AutofillHelper::SetProfiles(profile, &empty); 94 SetProfiles(profile, &empty);
90 } 95 }
91 96
92 void AutofillSyncPerfTest::Cleanup() { 97 void AutofillSyncPerfTest::Cleanup() {
93 for (int i = 0; i < num_clients(); ++i) { 98 for (int i = 0; i < num_clients(); ++i) {
94 RemoveProfiles(i); 99 RemoveProfiles(i);
95 } 100 }
96 ASSERT_TRUE(AwaitQuiescence()); 101 ASSERT_TRUE(AwaitQuiescence());
97 } 102 }
98 103
99 const AutofillProfile AutofillSyncPerfTest::NextAutofillProfile() { 104 const AutofillProfile AutofillSyncPerfTest::NextAutofillProfile() {
(...skipping 20 matching lines...) Expand all
120 return StringPrintf("Name%d" , n); 125 return StringPrintf("Name%d" , n);
121 } 126 }
122 127
123 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, P0) { 128 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, P0) {
124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 129 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
125 130
126 // TCM ID - 7557873. 131 // TCM ID - 7557873.
127 AddProfiles(0, kNumProfiles); 132 AddProfiles(0, kNumProfiles);
128 base::TimeDelta dt = 133 base::TimeDelta dt =
129 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 134 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
130 ASSERT_EQ(kNumProfiles, AutofillHelper::GetProfileCount(1)); 135 ASSERT_EQ(kNumProfiles, GetProfileCount(1));
131 SyncTimingHelper::PrintResult("autofill", "add", dt); 136 SyncTimingHelper::PrintResult("autofill", "add", dt);
132 137
133 // TCM ID - 7549835. 138 // TCM ID - 7549835.
134 UpdateProfiles(0); 139 UpdateProfiles(0);
135 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 140 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
136 ASSERT_EQ(kNumProfiles, AutofillHelper::GetProfileCount(1)); 141 ASSERT_EQ(kNumProfiles, GetProfileCount(1));
137 SyncTimingHelper::PrintResult("autofill", "update", dt); 142 SyncTimingHelper::PrintResult("autofill", "update", dt);
138 143
139 // TCM ID - 7553678. 144 // TCM ID - 7553678.
140 RemoveProfiles(0); 145 RemoveProfiles(0);
141 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 146 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
142 ASSERT_EQ(0, AutofillHelper::GetProfileCount(1)); 147 ASSERT_EQ(0, GetProfileCount(1));
143 SyncTimingHelper::PrintResult("autofill", "delete", dt); 148 SyncTimingHelper::PrintResult("autofill", "delete", dt);
144 } 149 }
145 150
146 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) { 151 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) {
147 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 152 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
148 153
149 for (int i = 0; i < kNumBenchmarkPoints; ++i) { 154 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
150 int num_profiles = kBenchmarkPoints[i]; 155 int num_profiles = kBenchmarkPoints[i];
151 AddProfiles(0, num_profiles); 156 AddProfiles(0, num_profiles);
152 base::TimeDelta dt_add = 157 base::TimeDelta dt_add =
153 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 158 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
154 ASSERT_EQ(num_profiles, AutofillHelper::GetProfileCount(0)); 159 ASSERT_EQ(num_profiles, GetProfileCount(0));
155 ASSERT_TRUE(AutofillHelper::AllProfilesMatch()); 160 ASSERT_TRUE(AllProfilesMatch());
156 VLOG(0) << std::endl << "Add: " << num_profiles << " " 161 VLOG(0) << std::endl << "Add: " << num_profiles << " "
157 << dt_add.InSecondsF(); 162 << dt_add.InSecondsF();
158 163
159 UpdateProfiles(0); 164 UpdateProfiles(0);
160 base::TimeDelta dt_update = 165 base::TimeDelta dt_update =
161 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 166 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
162 ASSERT_EQ(num_profiles, AutofillHelper::GetProfileCount(0)); 167 ASSERT_EQ(num_profiles, GetProfileCount(0));
163 ASSERT_TRUE(AutofillHelper::AllProfilesMatch()); 168 ASSERT_TRUE(AllProfilesMatch());
164 VLOG(0) << std::endl << "Update: " << num_profiles << " " 169 VLOG(0) << std::endl << "Update: " << num_profiles << " "
165 << dt_update.InSecondsF(); 170 << dt_update.InSecondsF();
166 171
167 RemoveProfiles(0); 172 RemoveProfiles(0);
168 base::TimeDelta dt_delete = 173 base::TimeDelta dt_delete =
169 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 174 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
170 ASSERT_EQ(0, AutofillHelper::GetProfileCount(0)); 175 ASSERT_EQ(0, GetProfileCount(0));
171 ASSERT_TRUE(AutofillHelper::AllProfilesMatch()); 176 ASSERT_TRUE(AllProfilesMatch());
172 VLOG(0) << std::endl << "Delete: " << num_profiles << " " 177 VLOG(0) << std::endl << "Delete: " << num_profiles << " "
173 << dt_delete.InSecondsF(); 178 << dt_delete.InSecondsF();
174 179
175 Cleanup(); 180 Cleanup();
176 } 181 }
177 } 182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698