| 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 "base/stringprintf.h" | 5 #include "base/stringprintf.h" |
| 6 #include "chrome/browser/sync/profile_sync_service_harness.h" | 6 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 7 #include "chrome/test/live_sync/live_extensions_sync_test.h" | 7 #include "chrome/test/live_sync/live_extensions_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): Replicate these tests for apps. | 10 // TODO(braffert): Replicate these tests for apps. |
| 11 | 11 |
| 12 static const int kNumExtensions = 150; | 12 static const int kNumExtensions = 150; |
| 13 | |
| 14 // TODO(braffert): Consider the range / resolution of these test points. | |
| 15 static const int kNumBenchmarkPoints = 18; | 13 static const int kNumBenchmarkPoints = 18; |
| 16 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, |
| 17 150, 175, 200, 225, 250, 300, 350, 400, | 15 150, 175, 200, 225, 250, 300, 350, 400, |
| 18 500}; | 16 500}; |
| 19 | 17 |
| 20 // TODO(braffert): Move this class into its own .h/.cc files. What should the | |
| 21 // class files be named as opposed to the file containing the tests themselves? | |
| 22 class ExtensionsSyncPerfTest | 18 class ExtensionsSyncPerfTest |
| 23 : public TwoClientLiveExtensionsSyncTest { | 19 : public TwoClientLiveExtensionsSyncTest { |
| 24 public: | 20 public: |
| 25 ExtensionsSyncPerfTest() : extension_number_(0) {} | 21 ExtensionsSyncPerfTest() : extension_number_(0) {} |
| 26 | 22 |
| 27 // Adds |num_extensions| new unique extensions to |profile|. | 23 // Adds |num_extensions| new unique extensions to |profile|. |
| 28 void AddExtensions(int profile, int num_extensions); | 24 void AddExtensions(int profile, int num_extensions); |
| 29 | 25 |
| 30 // Updates the enabled/disabled state for all extensions in |profile|. | 26 // Updates the enabled/disabled state for all extensions in |profile|. |
| 31 void UpdateExtensions(int profile); | 27 void UpdateExtensions(int profile); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // TCM ID - 7563874. | 76 // TCM ID - 7563874. |
| 81 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Add) { | 77 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Add) { |
| 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 78 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 83 | 79 |
| 84 AddExtensions(0, kNumExtensions); | 80 AddExtensions(0, kNumExtensions); |
| 85 base::TimeDelta dt = | 81 base::TimeDelta dt = |
| 86 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 82 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 87 InstallExtensionsPendingForSync(GetProfile(1)); | 83 InstallExtensionsPendingForSync(GetProfile(1)); |
| 88 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 84 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 89 | 85 |
| 90 // TODO(braffert): Compare timings against some target value. | 86 SyncTimingHelper::PrintResult("extensions", "add", dt); |
| 91 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 92 } | 87 } |
| 93 | 88 |
| 94 // TCM ID - 7655397. | 89 // TCM ID - 7655397. |
| 95 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Update) { | 90 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Update) { |
| 96 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 97 | 92 |
| 98 AddExtensions(0, kNumExtensions); | 93 AddExtensions(0, kNumExtensions); |
| 99 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 94 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 100 InstallExtensionsPendingForSync(GetProfile(1)); | 95 InstallExtensionsPendingForSync(GetProfile(1)); |
| 101 | 96 |
| 102 UpdateExtensions(0); | 97 UpdateExtensions(0); |
| 103 base::TimeDelta dt = | 98 base::TimeDelta dt = |
| 104 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 99 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 105 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 100 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 106 | 101 |
| 107 // TODO(braffert): Compare timings against some target value. | 102 SyncTimingHelper::PrintResult("extensions", "update", dt); |
| 108 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 109 } | 103 } |
| 110 | 104 |
| 111 // TCM ID - 7567721. | 105 // TCM ID - 7567721. |
| 112 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Delete) { | 106 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Delete) { |
| 113 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 107 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 114 | 108 |
| 115 AddExtensions(0, kNumExtensions); | 109 AddExtensions(0, kNumExtensions); |
| 116 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 110 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 117 InstallExtensionsPendingForSync(GetProfile(1)); | 111 InstallExtensionsPendingForSync(GetProfile(1)); |
| 118 | 112 |
| 119 RemoveExtensions(0); | 113 RemoveExtensions(0); |
| 120 base::TimeDelta dt = | 114 base::TimeDelta dt = |
| 121 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 115 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 122 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 116 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 123 | 117 |
| 124 // TODO(braffert): Compare timings against some target value. | 118 SyncTimingHelper::PrintResult("extensions", "delete", dt); |
| 125 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | |
| 126 } | 119 } |
| 127 | 120 |
| 128 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, DISABLED_Benchmark) { | 121 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, DISABLED_Benchmark) { |
| 129 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 122 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 130 | 123 |
| 131 for (int i = 0; i < kNumBenchmarkPoints; ++i) { | 124 for (int i = 0; i < kNumBenchmarkPoints; ++i) { |
| 132 int num_extensions = kBenchmarkPoints[i]; | 125 int num_extensions = kBenchmarkPoints[i]; |
| 133 AddExtensions(0, num_extensions); | 126 AddExtensions(0, num_extensions); |
| 134 base::TimeDelta dt_add = | 127 base::TimeDelta dt_add = |
| 135 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 128 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 136 InstallExtensionsPendingForSync(GetProfile(1)); | 129 InstallExtensionsPendingForSync(GetProfile(1)); |
| 137 VLOG(0) << std::endl << "Add: " << num_extensions << " " | 130 VLOG(0) << std::endl << "Add: " << num_extensions << " " |
| 138 << dt_add.InSecondsF(); | 131 << dt_add.InSecondsF(); |
| 139 | 132 |
| 140 UpdateExtensions(0); | 133 UpdateExtensions(0); |
| 141 base::TimeDelta dt_update = | 134 base::TimeDelta dt_update = |
| 142 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 135 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 143 VLOG(0) << std::endl << "Update: " << num_extensions << " " | 136 VLOG(0) << std::endl << "Update: " << num_extensions << " " |
| 144 << dt_update.InSecondsF(); | 137 << dt_update.InSecondsF(); |
| 145 | 138 |
| 146 RemoveExtensions(0); | 139 RemoveExtensions(0); |
| 147 base::TimeDelta dt_delete = | 140 base::TimeDelta dt_delete = |
| 148 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 141 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 149 VLOG(0) << std::endl << "Delete: " << num_extensions << " " | 142 VLOG(0) << std::endl << "Delete: " << num_extensions << " " |
| 150 << dt_delete.InSecondsF(); | 143 << dt_delete.InSecondsF(); |
| 151 | 144 |
| 152 Cleanup(); | 145 Cleanup(); |
| 153 } | 146 } |
| 154 } | 147 } |
| OLD | NEW |