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

Side by Side Diff: chrome/test/live_sync/performance_live_autofill_sync_test.cc

Issue 7484007: Move sync performance tests into new target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-upload again Created 9 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/stringprintf.h"
6 #include "chrome/browser/autofill/autofill_common_test.h"
7 #include "chrome/browser/sync/profile_sync_service_harness.h"
8 #include "chrome/test/live_sync/live_autofill_sync_test.h"
9 #include "chrome/test/live_sync/live_sync_timing_helper.h"
10
11 static const int kNumProfiles = 150;
12
13 // TODO(braffert): Consider the range / resolution of these test points.
14 static const int kNumBenchmarkPoints = 18;
15 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
16 150, 175, 200, 225, 250, 300, 350, 400,
17 500};
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 PerformanceLiveAutofillSyncTest
22 : public TwoClientLiveAutofillSyncTest {
23 public:
24 PerformanceLiveAutofillSyncTest() : guid_number_(0), name_number_(0) {}
25
26 // Adds |num_profiles| new autofill profiles to the sync profile |profile|.
27 void AddProfiles(int profile, int num_profiles);
28
29 // Updates all autofill profiles for the sync profile |profile|.
30 void UpdateProfiles(int profile);
31
32 // Removes all bookmarks in the bookmark bar for |profile|.
33 void RemoveProfiles(int profile);
34
35 // Removes all autofill profiles in all sync profiles. Called between
36 // benchmark iterations.
37 void Cleanup();
38
39 private:
40 // Returns a new unique autofill profile.
41 const AutofillProfile NextAutofillProfile();
42
43 // Returns an unused unique guid.
44 const std::string NextGUID();
45
46 // Returns a unique guid based on the input integer |n|.
47 const std::string IntToGUID(int n);
48
49 // Returns a new unused unique name.
50 const std::string NextName();
51
52 // Returns a unique name based on the input integer |n|.
53 const std::string IntToName(int n);
54
55 int guid_number_;
56 int name_number_;
57 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveAutofillSyncTest);
58 };
59
60 void PerformanceLiveAutofillSyncTest::AddProfiles(int profile,
61 int num_profiles) {
62 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
63 std::vector<AutofillProfile> autofill_profiles;
64 for (size_t i = 0; i < all_profiles.size(); ++i) {
65 autofill_profiles.push_back(*all_profiles[i]);
66 }
67 for (int i = 0; i < num_profiles; ++i) {
68 autofill_profiles.push_back(NextAutofillProfile());
69 }
70 SetProfiles(profile, &autofill_profiles);
71 }
72
73 void PerformanceLiveAutofillSyncTest::UpdateProfiles(int profile) {
74 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
75 std::vector<AutofillProfile> autofill_profiles;
76 for (size_t i = 0; i < all_profiles.size(); ++i) {
77 autofill_profiles.push_back(*all_profiles[i]);
78 autofill_profiles.back().SetInfo(AutofillFieldType(NAME_FIRST),
79 UTF8ToUTF16(NextName()));
80 }
81 SetProfiles(profile, &autofill_profiles);
82 }
83
84 void PerformanceLiveAutofillSyncTest::RemoveProfiles(int profile) {
85 std::vector<AutofillProfile> empty;
86 SetProfiles(profile, &empty);
87 }
88
89 void PerformanceLiveAutofillSyncTest::Cleanup() {
90 for (int i = 0; i < num_clients(); ++i) {
91 RemoveProfiles(i);
92 }
93 ASSERT_TRUE(AwaitQuiescence());
94 }
95
96 const AutofillProfile PerformanceLiveAutofillSyncTest::NextAutofillProfile() {
97 AutofillProfile profile;
98 autofill_test::SetProfileInfoWithGuid(&profile, NextGUID().c_str(),
99 NextName().c_str(), "", "", "", "", "",
100 "", "", "", "", "", "", "");
101 return profile;
102 }
103
104 const std::string PerformanceLiveAutofillSyncTest::NextGUID() {
105 return IntToGUID(guid_number_++);
106 }
107
108 const std::string PerformanceLiveAutofillSyncTest::IntToGUID(int n) {
109 return StringPrintf("00000000-0000-0000-0000-%012X", n);
110 }
111
112 const std::string PerformanceLiveAutofillSyncTest::NextName() {
113 return IntToName(name_number_++);
114 }
115
116 const std::string PerformanceLiveAutofillSyncTest::IntToName(int n) {
117 return StringPrintf("Name%d" , n);
118 }
119
120 // TCM ID - 7557873.
121 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, Add) {
122 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
123
124 AddProfiles(0, kNumProfiles);
125 base::TimeDelta dt =
126 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
127 ASSERT_EQ(kNumProfiles, GetProfileCount(0));
128 ASSERT_TRUE(AllProfilesMatch());
129
130 // TODO(braffert): Compare timings against some target value.
131 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
132 }
133
134 // TCM ID - 7549835.
135 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, Update) {
136 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
137
138 AddProfiles(0, kNumProfiles);
139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
140
141 UpdateProfiles(0);
142 base::TimeDelta dt =
143 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
144 ASSERT_EQ(kNumProfiles, GetProfileCount(0));
145 ASSERT_TRUE(AllProfilesMatch());
146
147 // TODO(braffert): Compare timings against some target value.
148 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
149 }
150
151 // TCM ID - 7553678.
152 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, Delete) {
153 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
154
155 AddProfiles(0, kNumProfiles);
156 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
157
158 RemoveProfiles(0);
159 base::TimeDelta dt =
160 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
161 ASSERT_EQ(0, GetProfileCount(0));
162 ASSERT_TRUE(AllProfilesMatch());
163
164 // TODO(braffert): Compare timings against some target value.
165 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
166 }
167
168 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, DISABLED_Benchmark) {
169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
170
171 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
172 int num_profiles = kBenchmarkPoints[i];
173 AddProfiles(0, num_profiles);
174 base::TimeDelta dt_add =
175 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
176 ASSERT_EQ(num_profiles, GetProfileCount(0));
177 ASSERT_TRUE(AllProfilesMatch());
178 VLOG(0) << std::endl << "Add: " << num_profiles << " "
179 << dt_add.InSecondsF();
180
181 UpdateProfiles(0);
182 base::TimeDelta dt_update =
183 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
184 ASSERT_EQ(num_profiles, GetProfileCount(0));
185 ASSERT_TRUE(AllProfilesMatch());
186 VLOG(0) << std::endl << "Update: " << num_profiles << " "
187 << dt_update.InSecondsF();
188
189 RemoveProfiles(0);
190 base::TimeDelta dt_delete =
191 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
192 ASSERT_EQ(0, GetProfileCount(0));
193 ASSERT_TRUE(AllProfilesMatch());
194 VLOG(0) << std::endl << "Delete: " << num_profiles << " "
195 << dt_delete.InSecondsF();
196
197 Cleanup();
198 }
199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698