| 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/live_bookmarks_sync_test.h" | 6 #include "chrome/test/live_sync/live_bookmarks_sync_test.h" |
| 7 #include "chrome/test/live_sync/performance/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 | |
| 11 // TODO(braffert): Consider the range / resolution of these test points. | |
| 12 static const int kNumBenchmarkPoints = 18; | 10 static const int kNumBenchmarkPoints = 18; |
| 13 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, | 11 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, |
| 14 150, 175, 200, 225, 250, 300, 350, 400, | 12 150, 175, 200, 225, 250, 300, 350, 400, |
| 15 500}; | 13 500}; |
| 16 | 14 |
| 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 BookmarksSyncPerfTest | 15 class BookmarksSyncPerfTest |
| 20 : public TwoClientLiveBookmarksSyncTest { | 16 : public TwoClientLiveBookmarksSyncTest { |
| 21 public: | 17 public: |
| 22 BookmarksSyncPerfTest() : url_number(0), url_title_number(0) {} | 18 BookmarksSyncPerfTest() : url_number(0), url_title_number(0) {} |
| 23 | 19 |
| 24 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|. | 20 // Adds |num_urls| new unique bookmarks to the bookmark bar for |profile|. |
| 25 void AddURLs(int profile, int num_urls); | 21 void AddURLs(int profile, int num_urls); |
| 26 | 22 |
| 27 // Updates the URL for all bookmarks in the bookmark bar for |profile|. | 23 // Updates the URL for all bookmarks in the bookmark bar for |profile|. |
| 28 void UpdateURLs(int profile); | 24 void UpdateURLs(int profile); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Add) { | 83 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Add) { |
| 88 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 84 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 89 DisableVerifier(); | 85 DisableVerifier(); |
| 90 | 86 |
| 91 AddURLs(0, kNumBookmarks); | 87 AddURLs(0, kNumBookmarks); |
| 92 base::TimeDelta dt = | 88 base::TimeDelta dt = |
| 93 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 89 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 94 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); | 90 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); |
| 95 ASSERT_TRUE(AllModelsMatch()); | 91 ASSERT_TRUE(AllModelsMatch()); |
| 96 | 92 |
| 97 // TODO(braffert): Compare timings against some target value. | 93 SyncTimingHelper::PrintResult("bookmarks", "add", dt); |
| 98 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 99 } | 94 } |
| 100 | 95 |
| 101 // TCM ID - 7564762. | 96 // TCM ID - 7564762. |
| 102 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Update) { | 97 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Update) { |
| 103 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 98 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 104 DisableVerifier(); | 99 DisableVerifier(); |
| 105 | 100 |
| 106 AddURLs(0, kNumBookmarks); | 101 AddURLs(0, kNumBookmarks); |
| 107 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 102 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 108 | 103 |
| 109 UpdateURLs(0); | 104 UpdateURLs(0); |
| 110 base::TimeDelta dt = | 105 base::TimeDelta dt = |
| 111 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 106 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 112 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); | 107 ASSERT_EQ(kNumBookmarks, GetBookmarkBarNode(0)->child_count()); |
| 113 ASSERT_TRUE(AllModelsMatch()); | 108 ASSERT_TRUE(AllModelsMatch()); |
| 114 | 109 |
| 115 // TODO(braffert): Compare timings against some target value. | 110 SyncTimingHelper::PrintResult("bookmarks", "update", dt); |
| 116 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 117 } | 111 } |
| 118 | 112 |
| 119 // TCM ID - 7566626. | 113 // TCM ID - 7566626. |
| 120 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Delete) { | 114 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, Delete) { |
| 121 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 115 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 122 DisableVerifier(); | 116 DisableVerifier(); |
| 123 | 117 |
| 124 AddURLs(0, kNumBookmarks); | 118 AddURLs(0, kNumBookmarks); |
| 125 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 119 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 126 | 120 |
| 127 RemoveURLs(0); | 121 RemoveURLs(0); |
| 128 base::TimeDelta dt = | 122 base::TimeDelta dt = |
| 129 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 123 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 130 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); | 124 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); |
| 131 ASSERT_TRUE(AllModelsMatch()); | 125 ASSERT_TRUE(AllModelsMatch()); |
| 132 | 126 |
| 133 // TODO(braffert): Compare timings against some target value. | 127 SyncTimingHelper::PrintResult("bookmarks", "delete", dt); |
| 134 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 135 } | 128 } |
| 136 | 129 |
| 137 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, DISABLED_Benchmark) { | 130 IN_PROC_BROWSER_TEST_F(BookmarksSyncPerfTest, DISABLED_Benchmark) { |
| 138 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 131 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 139 DisableVerifier(); | 132 DisableVerifier(); |
| 140 | 133 |
| 141 for (int i = 0; i < kNumBenchmarkPoints; ++i) { | 134 for (int i = 0; i < kNumBenchmarkPoints; ++i) { |
| 142 int num_bookmarks = kBenchmarkPoints[i]; | 135 int num_bookmarks = kBenchmarkPoints[i]; |
| 143 AddURLs(0, num_bookmarks); | 136 AddURLs(0, num_bookmarks); |
| 144 base::TimeDelta dt_add = | 137 base::TimeDelta dt_add = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 160 base::TimeDelta dt_delete = | 153 base::TimeDelta dt_delete = |
| 161 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 154 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 162 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); | 155 ASSERT_EQ(0, GetBookmarkBarNode(0)->child_count()); |
| 163 ASSERT_TRUE(AllModelsMatch()); | 156 ASSERT_TRUE(AllModelsMatch()); |
| 164 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " | 157 VLOG(0) << std::endl << "Delete: " << num_bookmarks << " " |
| 165 << dt_delete.InSecondsF(); | 158 << dt_delete.InSecondsF(); |
| 166 | 159 |
| 167 Cleanup(); | 160 Cleanup(); |
| 168 } | 161 } |
| 169 } | 162 } |
| OLD | NEW |