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

Side by Side Diff: chrome/test/live_sync/performance/bookmarks_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 "chrome/browser/sync/profile_sync_service_harness.h" 5 #include "chrome/browser/sync/profile_sync_service_harness.h"
6 #include "chrome/test/live_sync/live_bookmarks_sync_test.h" 6 #include "chrome/test/live_sync/live_bookmarks_sync_test.h"
7 #include "chrome/test/live_sync/live_sync_timing_helper.h" 7 #include "chrome/test/live_sync/performance/sync_timing_helper.h"
8 8
9 static const int kNumBookmarks = 150; 9 static const int kNumBookmarks = 150;
10 10
11 // TODO(braffert): Consider the range / resolution of these test points. 11 // TODO(braffert): Consider the range / resolution of these test points.
12 static const int kNumBenchmarkPoints = 18; 12 static const int kNumBenchmarkPoints = 18;
13 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, 13 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
14 150, 175, 200, 225, 250, 300, 350, 400, 14 150, 175, 200, 225, 250, 300, 350, 400,
15 500}; 15 500};
16 16
17 // TODO(braffert): Move this class into its own .h/.cc files. What should the 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? 18 // class files be named as opposed to the file containing the tests themselves?
19 class PerformanceLiveBookmarksSyncTest 19 class BookmarksSyncPerfTest
20 : public TwoClientLiveBookmarksSyncTest { 20 : public TwoClientLiveBookmarksSyncTest {
21 public: 21 public:
22 PerformanceLiveBookmarksSyncTest() : url_number(0), url_title_number(0) {} 22 BookmarksSyncPerfTest() : url_number(0), url_title_number(0) {}
23 23
24 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|. 24 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|.
25 void AddURLs(int profile, int num_urls); 25 void AddURLs(int profile, int num_urls);
26 26
27 // Updates the URL for all bookmarks in the bookmark bar for |profile|. 27 // Updates the URL for all bookmarks in the bookmark bar for |profile|.
28 void UpdateURLs(int profile); 28 void UpdateURLs(int profile);
29 29
30 // Removes all bookmarks in the bookmark bar for |profile|. 30 // Removes all bookmarks in the bookmark bar for |profile|.
31 void RemoveURLs(int profile); 31 void RemoveURLs(int profile);
32 32
33 // Remvoes all bookmarks in the bookmark bars for all profiles. Called 33 // Remvoes all bookmarks in the bookmark bars for all profiles. Called
34 // between benchmark iterations. 34 // between benchmark iterations.
35 void Cleanup(); 35 void Cleanup();
36 36
37 private: 37 private:
38 // Returns a new unique bookmark URL. 38 // Returns a new unique bookmark URL.
39 std::string NextIndexedURL(); 39 std::string NextIndexedURL();
40 40
41 // Returns a new unique bookmark title. 41 // Returns a new unique bookmark title.
42 std::wstring NextIndexedURLTitle(); 42 std::wstring NextIndexedURLTitle();
43 43
44 int url_number; 44 int url_number;
45 int url_title_number; 45 int url_title_number;
46 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveBookmarksSyncTest); 46 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest);
47 }; 47 };
48 48
49 void PerformanceLiveBookmarksSyncTest::AddURLs(int profile, int num_urls) { 49 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) {
50 for (int i = 0; i < num_urls; ++i) { 50 for (int i = 0; i < num_urls; ++i) {
51 ASSERT_TRUE(AddURL( 51 ASSERT_TRUE(AddURL(
52 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); 52 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL);
53 } 53 }
54 } 54 }
55 55
56 void PerformanceLiveBookmarksSyncTest::UpdateURLs(int profile) { 56 void BookmarksSyncPerfTest::UpdateURLs(int profile) {
57 for (int i = 0; i < GetBookmarkBarNode(profile)->child_count(); ++i) { 57 for (int i = 0; i < GetBookmarkBarNode(profile)->child_count(); ++i) {
58 ASSERT_TRUE(SetURL(profile, GetBookmarkBarNode(profile)->GetChild(i), 58 ASSERT_TRUE(SetURL(profile, GetBookmarkBarNode(profile)->GetChild(i),
59 GURL(NextIndexedURL()))); 59 GURL(NextIndexedURL())));
60 } 60 }
61 } 61 }
62 62
63 void PerformanceLiveBookmarksSyncTest::RemoveURLs(int profile) { 63 void BookmarksSyncPerfTest::RemoveURLs(int profile) {
64 while (!GetBookmarkBarNode(profile)->empty()) 64 while (GetBookmarkBarNode(profile)->child_count()) {
65 Remove(profile, GetBookmarkBarNode(profile), 0); 65 Remove(profile, GetBookmarkBarNode(profile), 0);
66 }
66 } 67 }
67 68
68 void PerformanceLiveBookmarksSyncTest::Cleanup() { 69 void BookmarksSyncPerfTest::Cleanup() {
69 for (int i = 0; i < num_clients(); ++i) { 70 for (int i = 0; i < num_clients(); ++i) {
70 RemoveURLs(i); 71 RemoveURLs(i);
71 } 72 }
72 ASSERT_TRUE(AwaitQuiescence()); 73 ASSERT_TRUE(AwaitQuiescence());
73 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 74 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
74 ASSERT_TRUE(AllModelsMatch()); 75 ASSERT_TRUE(AllModelsMatch());
75 } 76 }
76 77
77 std::string PerformanceLiveBookmarksSyncTest::NextIndexedURL() { 78 std::string BookmarksSyncPerfTest::NextIndexedURL() {
78 return IndexedURL(url_number++); 79 return IndexedURL(url_number++);
79 } 80 }
80 81
81 std::wstring PerformanceLiveBookmarksSyncTest::NextIndexedURLTitle() { 82 std::wstring BookmarksSyncPerfTest::NextIndexedURLTitle() {
82 return IndexedURLTitle(url_title_number++); 83 return IndexedURLTitle(url_title_number++);
83 } 84 }
84 85
85 // TCM ID - 7556828. 86 // TCM ID - 7556828.
86 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Add) { 87 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Add) {
87 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
88 DisableVerifier(); 89 DisableVerifier();
89 90
90 AddURLs(0, kNumBookmarks); 91 AddURLs(0, kNumBookmarks);
91 base::TimeDelta dt = 92 base::TimeDelta dt =
92 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 93 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
93 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); 94 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
94 ASSERT_TRUE(AllModelsMatch()); 95 ASSERT_TRUE(AllModelsMatch());
95 96
96 // TODO(braffert): Compare timings against some target value. 97 // TODO(braffert): Compare timings against some target value.
97 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; 98 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
98 } 99 }
99 100
100 // TCM ID - 7564762. 101 // TCM ID - 7564762.
101 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Update) { 102 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Update) {
102 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 103 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
103 DisableVerifier(); 104 DisableVerifier();
104 105
105 AddURLs(0, kNumBookmarks); 106 AddURLs(0, kNumBookmarks);
106 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 107 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
107 108
108 UpdateURLs(0); 109 UpdateURLs(0);
109 base::TimeDelta dt = 110 base::TimeDelta dt =
110 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 111 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
111 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); 112 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count());
112 ASSERT_TRUE(AllModelsMatch()); 113 ASSERT_TRUE(AllModelsMatch());
113 114
114 // TODO(braffert): Compare timings against some target value. 115 // TODO(braffert): Compare timings against some target value.
115 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; 116 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
116 } 117 }
117 118
118 // TCM ID - 7566626. 119 // TCM ID - 7566626.
119 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, Delete) { 120 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Delete) {
120 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 121 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
121 DisableVerifier(); 122 DisableVerifier();
122 123
123 AddURLs(0, kNumBookmarks); 124 AddURLs(0, kNumBookmarks);
124 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 125 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
125 126
126 RemoveURLs(0); 127 RemoveURLs(0);
127 base::TimeDelta dt = 128 base::TimeDelta dt =
128 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 129 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
129 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 130 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
130 ASSERT_TRUE(AllModelsMatch()); 131 ASSERT_TRUE(AllModelsMatch());
131 132
132 // TODO(braffert): Compare timings against some target value. 133 // TODO(braffert): Compare timings against some target value.
133 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; 134 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s";
134 } 135 }
135 136
136 IN_PROC_BROWSER_TEST_F(PerformanceLiveBookmarksSyncTest, DISABLED_Benchmark) { 137 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, DISABLED_Benchmark) {
137 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 138 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
138 DisableVerifier(); 139 DisableVerifier();
139 140
140 for (int i = 0; i < kNumBenchmarkPoints; ++i) { 141 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
141 int num_bookmarks = kBenchmarkPoints[i]; 142 int num_bookmarks = kBenchmarkPoints[i];
142 AddURLs(0, num_bookmarks); 143 AddURLs(0, num_bookmarks);
143 base::TimeDelta dt_add = 144 base::TimeDelta dt_add =
144 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 145 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
145 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count()); 146 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
146 ASSERT_TRUE(AllModelsMatch()); 147 ASSERT_TRUE(AllModelsMatch());
147 VLOG(0) << std::endl << "Add: " << num_bookmarks << " " 148 VLOG(0) << std::endl << "Add: " << num_bookmarks << " "
148 << dt_add.InSecondsF(); 149 << dt_add.InSecondsF();
149 150
150 UpdateURLs(0); 151 UpdateURLs(0);
151 base::TimeDelta dt_update = 152 base::TimeDelta dt_update =
152 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 153 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
153 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count()); 154 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
154 ASSERT_TRUE(AllModelsMatch()); 155 ASSERT_TRUE(AllModelsMatch());
155 VLOG(0) << std::endl << "Update: " << num_bookmarks << " " 156 VLOG(0) << std::endl << "Update: " << num_bookmarks << " "
156 << dt_update.InSecondsF(); 157 << dt_update.InSecondsF();
157 158
158 RemoveURLs(0); 159 RemoveURLs(0);
159 base::TimeDelta dt_delete = 160 base::TimeDelta dt_delete =
160 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 161 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
161 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); 162 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
162 ASSERT_TRUE(AllModelsMatch()); 163 ASSERT_TRUE(AllModelsMatch());
163 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " 164 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " "
164 << dt_delete.InSecondsF(); 165 << dt_delete.InSecondsF();
165 166
166 Cleanup(); 167 Cleanup();
167 } 168 }
168 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698