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