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

Side by Side Diff: chrome/test/live_sync/performance/autofill_sync_perf_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
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/autofill/autofill_common_test.h" 6 #include "chrome/browser/autofill/autofill_common_test.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_autofill_sync_test.h" 8 #include "chrome/test/live_sync/live_autofill_sync_test.h"
9 #include "chrome/test/live_sync/live_sync_timing_helper.h" 9 #include "chrome/test/live_sync/performance/sync_timing_helper.h"
10 10
11 static const int kNumProfiles = 150; 11 static const int kNumProfiles = 150;
12 12
13 // TODO(braffert): Consider the range / resolution of these test points. 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 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? 20 // class files be named as opposed to the file containing the tests themselves?
21 class PerformanceLiveAutofillSyncTest 21 class AutofillSyncPerfTest
22 : public TwoClientLiveAutofillSyncTest { 22 : public TwoClientLiveAutofillSyncTest {
23 public: 23 public:
24 PerformanceLiveAutofillSyncTest() : guid_number_(0), name_number_(0) {} 24 AutofillSyncPerfTest() : guid_number_(0), name_number_(0) {}
25 25
26 // Adds |num_profiles| new autofill profiles to the sync profile |profile|. 26 // Adds |num_profiles| new autofill profiles to the sync profile |profile|.
27 void AddProfiles(int profile, int num_profiles); 27 void AddProfiles(int profile, int num_profiles);
28 28
29 // Updates all autofill profiles for the sync profile |profile|. 29 // Updates all autofill profiles for the sync profile |profile|.
30 void UpdateProfiles(int profile); 30 void UpdateProfiles(int profile);
31 31
32 // Removes all bookmarks in the bookmark bar for |profile|. 32 // Removes all bookmarks in the bookmark bar for |profile|.
33 void RemoveProfiles(int profile); 33 void RemoveProfiles(int profile);
34 34
(...skipping 12 matching lines...) Expand all
47 const std::string IntToGUID(int n); 47 const std::string IntToGUID(int n);
48 48
49 // Returns a new unused unique name. 49 // Returns a new unused unique name.
50 const std::string NextName(); 50 const std::string NextName();
51 51
52 // Returns a unique name based on the input integer |n|. 52 // Returns a unique name based on the input integer |n|.
53 const std::string IntToName(int n); 53 const std::string IntToName(int n);
54 54
55 int guid_number_; 55 int guid_number_;
56 int name_number_; 56 int name_number_;
57 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveAutofillSyncTest); 57 DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest);
58 }; 58 };
59 59
60 void PerformanceLiveAutofillSyncTest::AddProfiles(int profile, 60 void AutofillSyncPerfTest::AddProfiles(int profile,
61 int num_profiles) { 61 int num_profiles) {
62 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile); 62 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
63 std::vector<AutofillProfile> autofill_profiles; 63 std::vector<AutofillProfile> autofill_profiles;
64 for (size_t i = 0; i < all_profiles.size(); ++i) { 64 for (size_t i = 0; i < all_profiles.size(); ++i) {
65 autofill_profiles.push_back(*all_profiles[i]); 65 autofill_profiles.push_back(*all_profiles[i]);
66 } 66 }
67 for (int i = 0; i < num_profiles; ++i) { 67 for (int i = 0; i < num_profiles; ++i) {
68 autofill_profiles.push_back(NextAutofillProfile()); 68 autofill_profiles.push_back(NextAutofillProfile());
69 } 69 }
70 SetProfiles(profile, &autofill_profiles); 70 SetProfiles(profile, &autofill_profiles);
71 } 71 }
72 72
73 void PerformanceLiveAutofillSyncTest::UpdateProfiles(int profile) { 73 void AutofillSyncPerfTest::UpdateProfiles(int profile) {
74 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile); 74 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
75 std::vector<AutofillProfile> autofill_profiles; 75 std::vector<AutofillProfile> autofill_profiles;
76 for (size_t i = 0; i < all_profiles.size(); ++i) { 76 for (size_t i = 0; i < all_profiles.size(); ++i) {
77 autofill_profiles.push_back(*all_profiles[i]); 77 autofill_profiles.push_back(*all_profiles[i]);
78 autofill_profiles.back().SetInfo(AutofillFieldType(NAME_FIRST), 78 autofill_profiles.back().SetInfo(AutofillFieldType(NAME_FIRST),
79 UTF8ToUTF16(NextName())); 79 UTF8ToUTF16(NextName()));
80 } 80 }
81 SetProfiles(profile, &autofill_profiles); 81 SetProfiles(profile, &autofill_profiles);
82 } 82 }
83 83
84 void PerformanceLiveAutofillSyncTest::RemoveProfiles(int profile) { 84 void AutofillSyncPerfTest::RemoveProfiles(int profile) {
85 std::vector<AutofillProfile> empty; 85 std::vector<AutofillProfile> empty;
86 SetProfiles(profile, &empty); 86 SetProfiles(profile, &empty);
87 } 87 }
88 88
89 void PerformanceLiveAutofillSyncTest::Cleanup() { 89 void AutofillSyncPerfTest::Cleanup() {
90 for (int i = 0; i < num_clients(); ++i) { 90 for (int i = 0; i < num_clients(); ++i) {
91 RemoveProfiles(i); 91 RemoveProfiles(i);
92 } 92 }
93 ASSERT_TRUE(AwaitQuiescence()); 93 ASSERT_TRUE(AwaitQuiescence());
94 } 94 }
95 95
96 const AutofillProfile PerformanceLiveAutofillSyncTest::NextAutofillProfile() { 96 const AutofillProfile AutofillSyncPerfTest::NextAutofillProfile() {
97 AutofillProfile profile; 97 AutofillProfile profile;
98 autofill_test::SetProfileInfoWithGuid(&profile, NextGUID().c_str(), 98 autofill_test::SetProfileInfoWithGuid(&profile, NextGUID().c_str(),
99 NextName().c_str(), "", "", "", "", "", 99 NextName().c_str(), "", "", "", "", "",
100 "", "", "", "", "", "", ""); 100 "", "", "", "", "", "", "");
101 return profile; 101 return profile;
102 } 102 }
103 103
104 const std::string PerformanceLiveAutofillSyncTest::NextGUID() { 104 const std::string AutofillSyncPerfTest::NextGUID() {
105 return IntToGUID(guid_number_++); 105 return IntToGUID(guid_number_++);
106 } 106 }
107 107
108 const std::string PerformanceLiveAutofillSyncTest::IntToGUID(int n) { 108 const std::string AutofillSyncPerfTest::IntToGUID(int n) {
109 return StringPrintf("00000000-0000-0000-0000-%012X", n); 109 return StringPrintf("00000000-0000-0000-0000-%012X", n);
110 } 110 }
111 111
112 const std::string PerformanceLiveAutofillSyncTest::NextName() { 112 const std::string AutofillSyncPerfTest::NextName() {
113 return IntToName(name_number_++); 113 return IntToName(name_number_++);
114 } 114 }
115 115
116 const std::string PerformanceLiveAutofillSyncTest::IntToName(int n) { 116 const std::string AutofillSyncPerfTest::IntToName(int n) {
117 return StringPrintf("Name%d" , n); 117 return StringPrintf("Name%d" , n);
118 } 118 }
119 119
120 // TCM ID - 7557873. 120 // TCM ID - 7557873.
121 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, Add) { 121 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Add) {
122 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 122 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
123 123
124 AddProfiles(0, kNumProfiles); 124 AddProfiles(0, kNumProfiles);
125 base::TimeDelta dt = 125 base::TimeDelta dt =
126 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 126 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
127 ASSERT_EQ(kNumProfiles, GetProfileCount(0)); 127 ASSERT_EQ(kNumProfiles, GetProfileCount(0));
128 ASSERT_TRUE(AllProfilesMatch()); 128 ASSERT_TRUE(AllProfilesMatch());
129 129
130 // TODO(braffert): Compare timings against some target value. 130 // TODO(braffert): Compare timings against some target value.
131 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; 131 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
132 } 132 }
133 133
134 // TCM ID - 7549835. 134 // TCM ID - 7549835.
135 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, Update) { 135 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Update) {
136 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 136 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
137 137
138 AddProfiles(0, kNumProfiles); 138 AddProfiles(0, kNumProfiles);
139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 139 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
140 140
141 UpdateProfiles(0); 141 UpdateProfiles(0);
142 base::TimeDelta dt = 142 base::TimeDelta dt =
143 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 143 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
144 ASSERT_EQ(kNumProfiles, GetProfileCount(0)); 144 ASSERT_EQ(kNumProfiles, GetProfileCount(0));
145 ASSERT_TRUE(AllProfilesMatch()); 145 ASSERT_TRUE(AllProfilesMatch());
146 146
147 // TODO(braffert): Compare timings against some target value. 147 // TODO(braffert): Compare timings against some target value.
148 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; 148 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
149 } 149 }
150 150
151 // TCM ID - 7553678. 151 // TCM ID - 7553678.
152 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, Delete) { 152 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, Delete) {
153 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 153 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
154 154
155 AddProfiles(0, kNumProfiles); 155 AddProfiles(0, kNumProfiles);
156 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 156 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
157 157
158 RemoveProfiles(0); 158 RemoveProfiles(0);
159 base::TimeDelta dt = 159 base::TimeDelta dt =
160 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 160 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
161 ASSERT_EQ(0, GetProfileCount(0)); 161 ASSERT_EQ(0, GetProfileCount(0));
162 ASSERT_TRUE(AllProfilesMatch()); 162 ASSERT_TRUE(AllProfilesMatch());
163 163
164 // TODO(braffert): Compare timings against some target value. 164 // TODO(braffert): Compare timings against some target value.
165 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; 165 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
166 } 166 }
167 167
168 IN_PROC_BROWSER_TEST_F(PerformanceLiveAutofillSyncTest, DISABLED_Benchmark) { 168 IN_PROC_BROWSER_TEST_F(AutofillSyncPerfTest, DISABLED_Benchmark) {
169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
170 170
171 for (int i = 0; i < kNumBenchmarkPoints; ++i) { 171 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
172 int num_profiles = kBenchmarkPoints[i]; 172 int num_profiles = kBenchmarkPoints[i];
173 AddProfiles(0, num_profiles); 173 AddProfiles(0, num_profiles);
174 base::TimeDelta dt_add = 174 base::TimeDelta dt_add =
175 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 175 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
176 ASSERT_EQ(num_profiles, GetProfileCount(0)); 176 ASSERT_EQ(num_profiles, GetProfileCount(0));
177 ASSERT_TRUE(AllProfilesMatch()); 177 ASSERT_TRUE(AllProfilesMatch());
178 VLOG(0) << std::endl << "Add: " << num_profiles << " " 178 VLOG(0) << std::endl << "Add: " << num_profiles << " "
179 << dt_add.InSecondsF(); 179 << dt_add.InSecondsF();
180 180
181 UpdateProfiles(0); 181 UpdateProfiles(0);
182 base::TimeDelta dt_update = 182 base::TimeDelta dt_update =
183 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 183 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
184 ASSERT_EQ(num_profiles, GetProfileCount(0)); 184 ASSERT_EQ(num_profiles, GetProfileCount(0));
185 ASSERT_TRUE(AllProfilesMatch()); 185 ASSERT_TRUE(AllProfilesMatch());
186 VLOG(0) << std::endl << "Update: " << num_profiles << " " 186 VLOG(0) << std::endl << "Update: " << num_profiles << " "
187 << dt_update.InSecondsF(); 187 << dt_update.InSecondsF();
188 188
189 RemoveProfiles(0); 189 RemoveProfiles(0);
190 base::TimeDelta dt_delete = 190 base::TimeDelta dt_delete =
191 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 191 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
192 ASSERT_EQ(0, GetProfileCount(0)); 192 ASSERT_EQ(0, GetProfileCount(0));
193 ASSERT_TRUE(AllProfilesMatch()); 193 ASSERT_TRUE(AllProfilesMatch());
194 VLOG(0) << std::endl << "Delete: " << num_profiles << " " 194 VLOG(0) << std::endl << "Delete: " << num_profiles << " "
195 << dt_delete.InSecondsF(); 195 << dt_delete.InSecondsF();
196 196
197 Cleanup(); 197 Cleanup();
198 } 198 }
199 } 199 }
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sync_timing_helper.cc ('k') | chrome/test/live_sync/performance/bookmarks_sync_perf_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698