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

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: marking benchmark test as disabled 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 #include "chrome/browser/sync/profile_sync_service_harness.h"
6 #include "chrome/test/live_sync/live_bookmarks_sync_test.h"
7 #include "chrome/test/live_sync/live_sync_timing_helper.h"
8
9 static const int kNumBookmarks = 150;
10
11 // TODO(braffert): Consider the range / resolution of these test points.
12 static const int kNumBenchmarkPoints = 18;
13 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
14 150, 175, 200, 225, 250, 300, 350, 400,
15 500};
16
17 // TODO(braffert): Move this class into its own .h/.cc files. What should the
18 // class files be named as opposed to the file containing the tests themselves?
19 class PerformanceLiveBookmarksSyncTest
20 : public TwoClientLiveBookmarksSyncTest {
21 public:
22 PerformanceLiveBookmarksSyncTest() : url_number(0), url_title_number(0) {}
23
24 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|.
25 void AddURLs(int profile, int num_urls);
26
27 // Updates the URL for all bookmarks in the bookmark bar for |profile|.
28 void UpdateURLs(int profile);
29
30 // Removes all bookmarks in the bookmark bar for |profile|.
31 void RemoveURLs(int profile);
32
33 // Remvoes all bookmarks in the bookmark bars for all profiles. Called
34 // between benchmark iterations.
35 void Cleanup();
36
37 private:
38 // Returns a new unique bookmark URL.
39 std::string NextIndexedURL();
40
41 // Returns a new unique bookmark title.
42 std::wstring NextIndexedURLTitle();
43
44 int url_number;
45 int url_title_number;
46 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveBookmarksSyncTest);
47 };
48
49 void PerformanceLiveBookmarksSyncTest::AddURLs(int profile, int num_urls) {
50 for (int i = 0; i < num_urls; ++i) {
51 ASSERT_TRUE(AddURL(
52 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL);
53 }
54 }
55
56 void PerformanceLiveBookmarksSyncTest::UpdateURLs(int profile) {
57 for (int i = 0; i < GetBookmarkBarNode(profile)->child_count(); ++i) {
58 ASSERT_TRUE(SetURL(profile, GetBookmarkBarNode(profile)->GetChild(i),
59 GURL(NextIndexedURL())));
60 }
61 }
62
63 void PerformanceLiveBookmarksSyncTest::RemoveURLs(int profile) {
64 while (GetBookmarkBarNode(profile)->child_count()) {
65 Remove(profile, GetBookmarkBarNode(profile), 0);
66 }
67 }
68
69 void PerformanceLiveBookmarksSyncTest::Cleanup() {
70 for (int i = 0; i < num_clients(); ++i) {
71 RemoveURLs(i);
72 }
73 ASSERT_TRUE(AwaitQuiescence());
74 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
75 ASSERT_TRUE(AllModelsMatch());
76 }
77
78 std::string PerformanceLiveBookmarksSyncTest::NextIndexedURL() {
79 return IndexedURL(url_number++);
80 }
81
82 std::wstring PerformanceLiveBookmarksSyncTest::NextIndexedURLTitle() {
83 return IndexedURLTitle(url_title_number++);
84 }
85
86 // TODO(braffert): Possibly split each of these into separate up / down test
87 // cases?
88 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Add) {
anna 2011/06/21 19:46:59 TCM ID - 7556828
89 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
90 DisableVerifier();
91
92 DisableNetwork(GetProfile(1));
93 AddURLs(0, kNumBookmarks);
94 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
95 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
96 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
97
98 EnableNetwork(GetProfile(1));
99 base::TimeDelta dt_down =
100 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
101 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
102 ASSERT_TRUE(AllModelsMatch());
103
104 // TODO(braffert): Compare timings against some target value.
105 }
106
107 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Update) {
anna 2011/06/21 19:46:59 TCM ID - 7564762
108 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
109 DisableVerifier();
110
111 AddURLs(0, kNumBookmarks);
112 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
113 ASSERT_TRUE(AllModelsMatch());
114
115 DisableNetwork(GetProfile(1));
116 UpdateURLs(0);
117 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
118 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
119 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
120 ASSERT_FALSE(AllModelsMatch());
121
122 EnableNetwork(GetProfile(1));
123 base::TimeDelta dt_down =
124 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
125 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
126 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
127
128 // TODO(braffert): Compare timings against some target value.
129 }
130
131 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Delete) {
anna 2011/06/21 19:46:59 TCM ID - 7566626
132 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
133 DisableVerifier();
134
135 AddURLs(0, kNumBookmarks);
136 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
137 ASSERT_TRUE(AllModelsMatch());
138
139 DisableNetwork(GetProfile(1));
140 RemoveURLs(0);
141 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
142 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
143 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(1)->child_count());
144
145 EnableNetwork(GetProfile(1));
146 base::TimeDelta dt_down =
147 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
148 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
149 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
150
151 // TODO(braffert): Compare timings against some target value.
152 }
153
154 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, DISABLED_Benchmark) {
155 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
156 DisableVerifier();
157
158 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
159 int num_bookmarks = kBenchmarkPoints[i];
160
161 // Disable client 1. Add bookmarks and time commit by client 0.
anna 2011/06/21 19:46:59 To ensure that we account for possible perf issues
162 DisableNetwork(GetProfile(1));
163 AddURLs(0, num_bookmarks);
164 base::TimeDelta dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
165 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
166 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
167
168 // Enable client 1 and time update (new bookmarks).
169 EnableNetwork(GetProfile(1));
170 base::TimeDelta dt_down =
171 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
172 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
173 ASSERT_TRUE(AllModelsMatch());
174
175 VLOG(0) << std::endl << "Add: " << num_bookmarks << " "
176 << dt_up.InSecondsF() << " " << dt_down.InSecondsF();
177
178 // Disable client 1. Modify bookmarks and time commit by client 0.
179 DisableNetwork(GetProfile(1));
180 UpdateURLs(0);
181 dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
182 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
183 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(1)->child_count());
184 ASSERT_FALSE(AllModelsMatch());
185
186 // Enable client 1 and time update (changed bookmarks).
187 EnableNetwork(GetProfile(1));
188 dt_down =
189 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
190 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
191 ASSERT_TRUE(AllModelsMatch());
192
193 VLOG(0) << std::endl << "Update: " << num_bookmarks << " "
194 << dt_up.InSecondsF() << " " << dt_down.InSecondsF();
195
196 // Disable client 1. Delete bookmarks and time commit by client 0.
197 DisableNetwork(GetProfile(1));
198 RemoveURLs(0);
199 dt_up = LiveSyncTimingHelper::TimeSyncCycle(GetClient(0));
200 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
201 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(1)->child_count());
202
203 // Enable client 1 and time update (deleted bookmarks).
204 EnableNetwork(GetProfile(1));
205 dt_down =
206 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
207 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
208 ASSERT_EQ(0, GetBookmarkBarNode(1)->child_count());
209
210 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " "
211 << dt_up.InSecondsF() << " " << dt_down.InSecondsF();
212
213 Cleanup();
214 }
215 }
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sync_timing_helper.cc ('k') | chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698