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

Side by Side Diff: chrome/test/live_sync/performance/bookmarks_sync_perf_test.cc

Issue 7461109: Allow sync integration tests to operate on multiple datatypes: Typed Urls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback; rebase Created 9 years, 4 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/bookmarks_helper.h" 6 #include "chrome/test/live_sync/bookmarks_helper.h"
7 #include "chrome/test/live_sync/live_sync_test.h" 7 #include "chrome/test/live_sync/live_sync_test.h"
8 #include "chrome/test/live_sync/performance/sync_timing_helper.h" 8 #include "chrome/test/live_sync/performance/sync_timing_helper.h"
9 9
10 using bookmarks_helper::AddURL;
11 using bookmarks_helper::AllModelsMatch;
12 using bookmarks_helper::GetBookmarkBarNode;
13 using bookmarks_helper::IndexedURL;
14 using bookmarks_helper::IndexedURLTitle;
15 using bookmarks_helper::Remove;
16 using bookmarks_helper::SetURL;
17
10 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all 18 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all
11 // datatypes into a performance test base class, once it is possible to do so. 19 // datatypes into a performance test base class, once it is possible to do so.
12 static const int kNumBookmarks = 150; 20 static const int kNumBookmarks = 150;
13 static const int kNumBenchmarkPoints = 18; 21 static const int kNumBenchmarkPoints = 18;
14 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, 22 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
15 150, 175, 200, 225, 250, 300, 350, 400, 23 150, 175, 200, 225, 250, 300, 350, 400,
16 500}; 24 500};
17 25
18 class BookmarksSyncPerfTest : public LiveSyncTest { 26 class BookmarksSyncPerfTest : public LiveSyncTest {
19 public: 27 public:
(...skipping 25 matching lines...) Expand all
45 // Returns a new unique bookmark title. 53 // Returns a new unique bookmark title.
46 std::wstring NextIndexedURLTitle(); 54 std::wstring NextIndexedURLTitle();
47 55
48 int url_number_; 56 int url_number_;
49 int url_title_number_; 57 int url_title_number_;
50 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest); 58 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest);
51 }; 59 };
52 60
53 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) { 61 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) {
54 for (int i = 0; i < num_urls; ++i) { 62 for (int i = 0; i < num_urls; ++i) {
55 ASSERT_TRUE(BookmarksHelper::AddURL( 63 ASSERT_TRUE(AddURL(
56 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); 64 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL);
57 } 65 }
58 } 66 }
59 67
60 void BookmarksSyncPerfTest::UpdateURLs(int profile) { 68 void BookmarksSyncPerfTest::UpdateURLs(int profile) {
61 for (int i = 0; 69 for (int i = 0;
62 i < BookmarksHelper::GetBookmarkBarNode(profile)->child_count(); 70 i < GetBookmarkBarNode(profile)->child_count();
63 ++i) { 71 ++i) {
64 ASSERT_TRUE(BookmarksHelper::SetURL( 72 ASSERT_TRUE(SetURL(profile,
65 profile, BookmarksHelper::GetBookmarkBarNode(profile)->GetChild(i), 73 GetBookmarkBarNode(profile)->GetChild(i),
66 GURL(NextIndexedURL()))); 74 GURL(NextIndexedURL())));
67 } 75 }
68 } 76 }
69 77
70 void BookmarksSyncPerfTest::RemoveURLs(int profile) { 78 void BookmarksSyncPerfTest::RemoveURLs(int profile) {
71 while (!BookmarksHelper::GetBookmarkBarNode(profile)->empty()) { 79 while (!GetBookmarkBarNode(profile)->empty()) {
72 BookmarksHelper::Remove( 80 Remove(profile, GetBookmarkBarNode(profile), 0);
73 profile, BookmarksHelper::GetBookmarkBarNode(profile), 0);
74 } 81 }
75 } 82 }
76 83
77 int BookmarksSyncPerfTest::GetURLCount(int profile) { 84 int BookmarksSyncPerfTest::GetURLCount(int profile) {
78 return BookmarksHelper::GetBookmarkBarNode(profile)->child_count(); 85 return GetBookmarkBarNode(profile)->child_count();
79 } 86 }
80 87
81 void BookmarksSyncPerfTest::Cleanup() { 88 void BookmarksSyncPerfTest::Cleanup() {
82 for (int i = 0; i < num_clients(); ++i) { 89 for (int i = 0; i < num_clients(); ++i) {
83 RemoveURLs(i); 90 RemoveURLs(i);
84 } 91 }
85 ASSERT_TRUE(AwaitQuiescence()); 92 ASSERT_TRUE(AwaitQuiescence());
86 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count()); 93 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
87 ASSERT_TRUE(BookmarksHelper::AllModelsMatch()); 94 ASSERT_TRUE(AllModelsMatch());
88 } 95 }
89 96
90 std::string BookmarksSyncPerfTest::NextIndexedURL() { 97 std::string BookmarksSyncPerfTest::NextIndexedURL() {
91 return BookmarksHelper::IndexedURL(url_number_++); 98 return IndexedURL(url_number_++);
92 } 99 }
93 100
94 std::wstring BookmarksSyncPerfTest::NextIndexedURLTitle() { 101 std::wstring BookmarksSyncPerfTest::NextIndexedURLTitle() {
95 return BookmarksHelper::IndexedURLTitle(url_title_number_++); 102 return IndexedURLTitle(url_title_number_++);
96 } 103 }
97 104
98 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) { 105 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) {
99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 106 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
100 107
101 // TCM ID - 7556828. 108 // TCM ID - 7556828.
102 AddURLs(0, kNumBookmarks); 109 AddURLs(0, kNumBookmarks);
103 base::TimeDelta dt = 110 base::TimeDelta dt =
104 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 111 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
105 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); 112 ASSERT_EQ(kNumBookmarks, GetURLCount(1));
(...skipping 14 matching lines...) Expand all
120 127
121 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, DISABLED_Benchmark) { 128 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, DISABLED_Benchmark) {
122 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 129 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
123 DisableVerifier(); 130 DisableVerifier();
124 131
125 for (int i = 0; i < kNumBenchmarkPoints; ++i) { 132 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
126 int num_bookmarks = kBenchmarkPoints[i]; 133 int num_bookmarks = kBenchmarkPoints[i];
127 AddURLs(0, num_bookmarks); 134 AddURLs(0, num_bookmarks);
128 base::TimeDelta dt_add = 135 base::TimeDelta dt_add =
129 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 136 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
130 ASSERT_EQ(num_bookmarks, 137 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
131 BookmarksHelper::GetBookmarkBarNode(0)->child_count()); 138 ASSERT_TRUE(AllModelsMatch());
132 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
133 VLOG(0) << std::endl << "Add: " << num_bookmarks << " " 139 VLOG(0) << std::endl << "Add: " << num_bookmarks << " "
134 << dt_add.InSecondsF(); 140 << dt_add.InSecondsF();
135 141
136 UpdateURLs(0); 142 UpdateURLs(0);
137 base::TimeDelta dt_update = 143 base::TimeDelta dt_update =
138 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 144 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
139 ASSERT_EQ(num_bookmarks, 145 ASSERT_EQ(num_bookmarks, GetBookmarkBarNode(0)->child_count());
140 BookmarksHelper::GetBookmarkBarNode(0)->child_count()); 146 ASSERT_TRUE(AllModelsMatch());
141 ASSERT_TRUE(BookmarksHelper::AllModelsMatch());
142 VLOG(0) << std::endl << "Update: " << num_bookmarks << " " 147 VLOG(0) << std::endl << "Update: " << num_bookmarks << " "
143 << dt_update.InSecondsF(); 148 << dt_update.InSecondsF();
144 149
145 RemoveURLs(0); 150 RemoveURLs(0);
146 base::TimeDelta dt_delete = 151 base::TimeDelta dt_delete =
147 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 152 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
148 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count()); 153 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count());
149 ASSERT_TRUE(BookmarksHelper::AllModelsMatch()); 154 ASSERT_TRUE(AllModelsMatch());
150 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " 155 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " "
151 << dt_delete.InSecondsF(); 156 << dt_delete.InSecondsF();
152 157
153 Cleanup(); 158 Cleanup();
154 } 159 }
155 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698