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

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

Issue 7171003: Performance tests for bookmark sync. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Missing comments + extra refactoring Created 9 years, 6 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 /*
6 #include "base/time.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sync/profile_sync_service_harness.h"
9 #include "chrome/test/live_sync/live_bookmarks_sync_test.h"
10 */
Raghu Simha 2011/06/16 22:42:55 Remove this block if it's unnecessary.
braffert 2011/06/17 18:19:46 Done.
11
12 #include "chrome/browser/sync/profile_sync_service_harness.h"
13 #include "chrome/test/live_sync/live_bookmarks_sync_test.h"
14 #include "chrome/test/live_sync/live_sync_timing_helper.h"
15
16 static const int kNumBookmarks = 150;
17
18 // TODO(braffert): Consider the range / resolution of these test points.
19 static const int kNumBenchmarkPoints = 18;
20 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
21 150, 175, 200, 225, 250, 300, 350, 400,
22 500};
23
24 // TODO(braffert): Move this class into its own .h/.cc files. What should the
25 // class files be named as opposed to the file containing the tests themselves?
Raghu Simha 2011/06/16 22:42:55 How about naming the class LiveBookmarksSyncPerfor
26 class PerformanceLiveBookmarksSyncTest
27 : public TwoClientLiveBookmarksSyncTest {
28 public:
29 PerformanceLiveBookmarksSyncTest() : urlNumber(0), urlTitleNumber(0) {}
30
31 // Pairs the test class with the timer helper for measuring sync times.
32 void SetUp() OVERRIDE;
Raghu Simha 2011/06/16 22:42:55 With the change I've suggested to LiveSyncTimingHe
braffert 2011/06/17 18:19:46 Done.
33
34 // Adds |nURLs| new unique bookmarks to the bookmark bar for |profile|.
35 void AddURLs(int profile, int nURLs);
Raghu Simha 2011/06/16 22:42:55 Style guide recommends num_urls over nURLs.
braffert 2011/06/17 18:19:46 Done.
36
37 // Updates the URL for all bookmarks in the bookmark bar for |profile|.
38 void UpdateURLs(int profile);
39
40 // Removes all bookmarks in the bookmark bar for |profile|.
41 void RemoveURLs(int profile);
42
43 // Remvoes all bookmarks in the bookmark bars for all profiles. Called
44 // between benchmark iterations.
45 void Cleanup();
46
47 LiveSyncTimingHelper timing_helper;
Raghu Simha 2011/06/16 22:42:55 With the change I've suggested to LiveSyncTimingHe
braffert 2011/06/17 18:19:46 Done.
48
49 private:
50 // Returns a new unique bookmark URL.
51 GURL NextIndexedURL();
Raghu Simha 2011/06/16 22:42:55 IndexedURL returns a wstring while NextIndexedURL
braffert 2011/06/17 18:19:46 Taking the easy option here - just to keep this CL
52
53 // Returns a new unique bookmark title.
54 std::wstring NextIndexedURLTitle();
55
56 int urlNumber;
Raghu Simha 2011/06/16 22:42:55 Style guide recommends that variable names are low
braffert 2011/06/17 18:19:46 Done.
57 int urlTitleNumber;
58 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveBookmarksSyncTest);
59 };
60
61 void PerformanceLiveBookmarksSyncTest::SetUp() {
62 timing_helper.Setup(this);
63 LiveSyncTest::SetUp();
64 }
65
66 void PerformanceLiveBookmarksSyncTest::AddURLs(int profile, int nURLs) {
67 for (int i = 0; i < nURLs; ++i) {
68 ASSERT_TRUE(AddURL(
69 profile, 0, NextIndexedURLTitle(), NextIndexedURL()) != NULL);
70 }
71 }
72
73 void PerformanceLiveBookmarksSyncTest::UpdateURLs(int profile) {
74 for (int i = 0; i < GetBookmarkBarNode(profile)->child_count(); ++i) {
75 ASSERT_TRUE(SetURL(profile, GetBookmarkBarNode(profile)->GetChild(i),
76 NextIndexedURL()));
77 }
78 }
79
80 void PerformanceLiveBookmarksSyncTest::RemoveURLs(int profile) {
81 while (GetBookmarkBarNode(profile)->child_count()) {
82 Remove(profile, GetBookmarkBarNode(profile), 0);
83 }
84 }
85
86 void PerformanceLiveBookmarksSyncTest::Cleanup() {
87 for (int i = 0; i < num_clients(); ++i) {
88 RemoveURLs(i);
89 }
90 ASSERT_TRUE(AwaitQuiescence());
91 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
92 ASSERT_TRUE(AllModelsMatch());
93 }
94
95 GURL PerformanceLiveBookmarksSyncTest::NextIndexedURL() {
96 return GURL(IndexedURL(urlNumber++));
97 }
98
99 std::wstring PerformanceLiveBookmarksSyncTest::NextIndexedURLTitle() {
100 return IndexedURLTitle(urlTitleNumber++);
101 }
102
103 // TODO(braffert): Possibly split each of these into separate up / down test
104 // cases?
105 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Add) {
106 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
107 DisableVerifier();
108
109 DisableNetwork(GetProfile(1));
110 AddURLs(0, kNumBookmarks);
111 base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
112 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
113 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
114
115 EnableNetwork(GetProfile(1));
116 base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
117 GetClient(1));
118 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
119 ASSERT_TRUE(AllModelsMatch());
120
121 // TODO(braffert): Compare timings against some target value.
122 }
123
124 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Update) {
125 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
126 DisableVerifier();
127
128 AddURLs(0, kNumBookmarks);
129 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
130 ASSERT_TRUE(AllModelsMatch());
131
132 DisableNetwork(GetProfile(1));
133 UpdateURLs(0);
134 base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
135 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
136 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
137 ASSERT_FALSE(AllModelsMatch());
138
139 EnableNetwork(GetProfile(1));
140 base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
141 GetClient(1));
142 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
143 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
144
145 // TODO(braffert): Compare timings against some target value.
146 }
147
148 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Delete) {
149 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
150 DisableVerifier();
151
152 AddURLs(0, kNumBookmarks);
153 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
154 ASSERT_TRUE(AllModelsMatch());
155
156 DisableNetwork(GetProfile(1));
157 RemoveURLs(0);
158 base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
159 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
160 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
161
162 EnableNetwork(GetProfile(1));
163 base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
164 GetClient(1));
165 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
166 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
167
168 // TODO(braffert): Compare timings against some target value.
169 }
170
171 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Benchmark) {
172 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
173 DisableVerifier();
174
175 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
176 int numBookmarks = kBenchmarkPoints[i];
Raghu Simha 2011/06/16 22:42:55 numBookmarks -> num_bookmarks.
braffert 2011/06/17 18:19:46 Done. Curious - why do constants use a different
177
178 // Disable client 1. Add bookmarks and time commit by client 0.
179 DisableNetwork(GetProfile(1));
180 AddURLs(0, numBookmarks);
181 base::TimeDelta dt_up = timing_helper.TimeSyncCycle(GetClient(0));
182 ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
183 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
184
185 // Enable client 1 and time update (new bookmarks).
186 EnableNetwork(GetProfile(1));
187 base::TimeDelta dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0),
188 GetClient(1));
189 ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
190 ASSERT_TRUE(AllModelsMatch());
191
192 VLOG(0) << std::endl << "Add: " << numBookmarks << " " <<
193 static_cast<double>(numBookmarks) / dt_up.InSecondsF() << " " <<
194 static_cast<double>(numBookmarks) / dt_down.InSecondsF();
195
196 // Disable client 1. Modify bookmarks and time commit by client 0.
197 DisableNetwork(GetProfile(1));
198 UpdateURLs(0);
199 dt_up = timing_helper.TimeSyncCycle(GetClient(0));
200 ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
201 ASSERT_EQ(numBookmarks, GetBookmarkBarNode(1)->child_count());
202 ASSERT_FALSE(AllModelsMatch());
203
204 // Enable client 1 and time update (changed bookmarks).
205 EnableNetwork(GetProfile(1));
206 dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0), GetClient(1));
207 ASSERT_EQ(numBookmarks, GetBookmarkBarNode(0)->child_count());
208 ASSERT_TRUE(AllModelsMatch());
209
210 VLOG(0) << std::endl << "Update: " << numBookmarks << " " <<
211 static_cast<double>(numBookmarks) / dt_up.InSecondsF() << " " <<
212 static_cast<double>(numBookmarks) / dt_down.InSecondsF();
213
214 // Disable client 1. Delete bookmarks and time commit by client 0.
215 DisableNetwork(GetProfile(1));
216 RemoveURLs(0);
217 dt_up = timing_helper.TimeSyncCycle(GetClient(0));
218 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
219 ASSERT_EQ(numBookmarks, GetBookmarkBarNode(1)->child_count());
220
221 // Enable client 1 and time update (deleted bookmarks).
222 EnableNetwork(GetProfile(1));
223 dt_down = timing_helper.TimeMutualSyncCycle(GetClient(0), GetClient(1));
224 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
225 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
226
227 VLOG(0) << std::endl << "Delete: " << numBookmarks << " " <<
228 static_cast<double>(numBookmarks) / dt_up.InSecondsF() << " " <<
229 static_cast<double>(numBookmarks) / dt_down.InSecondsF();
230
231 Cleanup();
232 }
233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698