| OLD | NEW |
| 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 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all | 10 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all |
| 11 // datatypes into a performance test base class, once it is possible to do so. | 11 // datatypes into a performance test base class, once it is possible to do so. |
| 12 static const int kNumBookmarks = 150; | 12 static const int kNumBookmarks = 150; |
| 13 static const int kNumBenchmarkPoints = 18; | 13 static const int kNumBenchmarkPoints = 18; |
| 14 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, | 14 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, |
| 15 150, 175, 200, 225, 250, 300, 350, 400, | 15 150, 175, 200, 225, 250, 300, 350, 400, |
| 16 500}; | 16 500}; |
| 17 | 17 |
| 18 class BookmarksSyncPerfTest : public LiveSyncTest { | 18 class BookmarksSyncPerfTest : public LiveSyncTest { |
| 19 public: | 19 public: |
| 20 BookmarksSyncPerfTest() | 20 BookmarksSyncPerfTest() |
| 21 : LiveSyncTest(TWO_CLIENT), | 21 : LiveSyncTest(TWO_CLIENT), |
| 22 url_number(0), | 22 url_number_(0), |
| 23 url_title_number(0) {} | 23 url_title_number_(0) {} |
| 24 | 24 |
| 25 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|. | 25 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|. |
| 26 void AddURLs(int profile, int num_urls); | 26 void AddURLs(int profile, int num_urls); |
| 27 | 27 |
| 28 // Updates the URL for all bookmarks in the bookmark bar for |profile|. | 28 // Updates the URL for all bookmarks in the bookmark bar for |profile|. |
| 29 void UpdateURLs(int profile); | 29 void UpdateURLs(int profile); |
| 30 | 30 |
| 31 // Removes all bookmarks in the bookmark bar for |profile|. | 31 // Removes all bookmarks in the bookmark bar for |profile|. |
| 32 void RemoveURLs(int profile); | 32 void RemoveURLs(int profile); |
| 33 | 33 |
| 34 // Returns the number of bookmarks stored in the bookmark bar for |profile|. | 34 // Returns the number of bookmarks stored in the bookmark bar for |profile|. |
| 35 int GetURLCount(int profile); | 35 int GetURLCount(int profile); |
| 36 | 36 |
| 37 // Remvoes all bookmarks in the bookmark bars for all profiles. Called | 37 // Remvoes all bookmarks in the bookmark bars for all profiles. Called |
| 38 // between benchmark iterations. | 38 // between benchmark iterations. |
| 39 void Cleanup(); | 39 void Cleanup(); |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // Returns a new unique bookmark URL. | 42 // Returns a new unique bookmark URL. |
| 43 std::string NextIndexedURL(); | 43 std::string NextIndexedURL(); |
| 44 | 44 |
| 45 // Returns a new unique bookmark title. | 45 // Returns a new unique bookmark title. |
| 46 std::wstring NextIndexedURLTitle(); | 46 std::wstring NextIndexedURLTitle(); |
| 47 | 47 |
| 48 int url_number; | 48 int url_number_; |
| 49 int url_title_number; | 49 int url_title_number_; |
| 50 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest); | 50 DISALLOW_COPY_AND_ASSIGN(BookmarksSyncPerfTest); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) { | 53 void BookmarksSyncPerfTest::AddURLs(int profile, int num_urls) { |
| 54 for (int i = 0; i < num_urls; ++i) { | 54 for (int i = 0; i < num_urls; ++i) { |
| 55 ASSERT_TRUE(BookmarksHelper::AddURL( | 55 ASSERT_TRUE(BookmarksHelper::AddURL( |
| 56 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); | 56 profile, 0, NextIndexedURLTitle(), GURL(NextIndexedURL())) != NULL); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 81 void BookmarksSyncPerfTest::Cleanup() { | 81 void BookmarksSyncPerfTest::Cleanup() { |
| 82 for (int i = 0; i < num_clients(); ++i) { | 82 for (int i = 0; i < num_clients(); ++i) { |
| 83 RemoveURLs(i); | 83 RemoveURLs(i); |
| 84 } | 84 } |
| 85 ASSERT_TRUE(AwaitQuiescence()); | 85 ASSERT_TRUE(AwaitQuiescence()); |
| 86 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count()); | 86 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count()); |
| 87 ASSERT_TRUE(BookmarksHelper::AllModelsMatch()); | 87 ASSERT_TRUE(BookmarksHelper::AllModelsMatch()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 std::string BookmarksSyncPerfTest::NextIndexedURL() { | 90 std::string BookmarksSyncPerfTest::NextIndexedURL() { |
| 91 return BookmarksHelper::IndexedURL(url_number++); | 91 return BookmarksHelper::IndexedURL(url_number_++); |
| 92 } | 92 } |
| 93 | 93 |
| 94 std::wstring BookmarksSyncPerfTest::NextIndexedURLTitle() { | 94 std::wstring BookmarksSyncPerfTest::NextIndexedURLTitle() { |
| 95 return BookmarksHelper::IndexedURLTitle(url_title_number++); | 95 return BookmarksHelper::IndexedURLTitle(url_title_number_++); |
| 96 } | 96 } |
| 97 | 97 |
| 98 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) { | 98 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, P0) { |
| 99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 100 | 100 |
| 101 // TCM ID - 7556828. | 101 // TCM ID - 7556828. |
| 102 AddURLs(0, kNumBookmarks); | 102 AddURLs(0, kNumBookmarks); |
| 103 base::TimeDelta dt = | 103 base::TimeDelta dt = |
| 104 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 104 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 105 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); | 105 ASSERT_EQ(kNumBookmarks, GetURLCount(1)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 base::TimeDelta dt_delete = | 146 base::TimeDelta dt_delete = |
| 147 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 147 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 148 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count()); | 148 ASSERT_EQ(0, BookmarksHelper::GetBookmarkBarNode(0)->child_count()); |
| 149 ASSERT_TRUE(BookmarksHelper::AllModelsMatch()); | 149 ASSERT_TRUE(BookmarksHelper::AllModelsMatch()); |
| 150 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " | 150 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " |
| 151 << dt_delete.InSecondsF(); | 151 << dt_delete.InSecondsF(); |
| 152 | 152 |
| 153 Cleanup(); | 153 Cleanup(); |
| 154 } | 154 } |
| 155 } | 155 } |
| OLD | NEW |