| 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/live_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 | 13 |
| 14 // TODO(braffert): Consider the range / resolution of these test points. | 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 | 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? | 21 // class files be named as opposed to the file containing the tests themselves? |
| 22 class PerformanceLiveExtensionsSyncTest | 22 class ExtensionsSyncPerfTest |
| 23 : public TwoClientLiveExtensionsSyncTest { | 23 : public TwoClientLiveExtensionsSyncTest { |
| 24 public: | 24 public: |
| 25 PerformanceLiveExtensionsSyncTest() : extension_number_(0) {} | 25 ExtensionsSyncPerfTest() : extension_number_(0) {} |
| 26 | 26 |
| 27 // Adds |num_extensions| new unique extensions to |profile|. | 27 // Adds |num_extensions| new unique extensions to |profile|. |
| 28 void AddExtensions(int profile, int num_extensions); | 28 void AddExtensions(int profile, int num_extensions); |
| 29 | 29 |
| 30 // Updates the enabled/disabled state for all extensions in |profile|. | 30 // Updates the enabled/disabled state for all extensions in |profile|. |
| 31 void UpdateExtensions(int profile); | 31 void UpdateExtensions(int profile); |
| 32 | 32 |
| 33 // Uninstalls all currently installed extensions from |profile|. | 33 // Uninstalls all currently installed extensions from |profile|. |
| 34 void RemoveExtensions(int profile); | 34 void RemoveExtensions(int profile); |
| 35 | 35 |
| 36 // Uninstalls all extensions from all profiles. Called between benchmark | 36 // Uninstalls all extensions from all profiles. Called between benchmark |
| 37 // iterations. | 37 // iterations. |
| 38 void Cleanup(); | 38 void Cleanup(); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 int extension_number_; | 41 int extension_number_; |
| 42 DISALLOW_COPY_AND_ASSIGN(PerformanceLiveExtensionsSyncTest); | 42 DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 void PerformanceLiveExtensionsSyncTest::AddExtensions(int profile, | 45 void ExtensionsSyncPerfTest::AddExtensions(int profile, |
| 46 int num_extensions) { | 46 int num_extensions) { |
| 47 for (int i = 0; i < num_extensions; ++i) { | 47 for (int i = 0; i < num_extensions; ++i) { |
| 48 InstallExtension(GetProfile(profile), extension_number_++); | 48 InstallExtension(GetProfile(profile), extension_number_++); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void PerformanceLiveExtensionsSyncTest::UpdateExtensions(int profile) { | 52 void ExtensionsSyncPerfTest::UpdateExtensions(int profile) { |
| 53 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); | 53 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); |
| 54 for (std::vector<int>::iterator it = extensions.begin(); | 54 for (std::vector<int>::iterator it = extensions.begin(); |
| 55 it != extensions.end(); ++it) { | 55 it != extensions.end(); ++it) { |
| 56 if (IsExtensionEnabled(GetProfile(profile), *it)) { | 56 if (IsExtensionEnabled(GetProfile(profile), *it)) { |
| 57 DisableExtension(GetProfile(profile), *it); | 57 DisableExtension(GetProfile(profile), *it); |
| 58 } else { | 58 } else { |
| 59 EnableExtension(GetProfile(profile), *it); | 59 EnableExtension(GetProfile(profile), *it); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PerformanceLiveExtensionsSyncTest::RemoveExtensions(int profile) { | 64 void ExtensionsSyncPerfTest::RemoveExtensions(int profile) { |
| 65 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); | 65 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); |
| 66 for (std::vector<int>::iterator it = extensions.begin(); | 66 for (std::vector<int>::iterator it = extensions.begin(); |
| 67 it != extensions.end(); ++it) { | 67 it != extensions.end(); ++it) { |
| 68 UninstallExtension(GetProfile(profile), *it); | 68 UninstallExtension(GetProfile(profile), *it); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 void PerformanceLiveExtensionsSyncTest::Cleanup() { | 72 void ExtensionsSyncPerfTest::Cleanup() { |
| 73 for (int i = 0; i < num_clients(); ++i) { | 73 for (int i = 0; i < num_clients(); ++i) { |
| 74 RemoveExtensions(i); | 74 RemoveExtensions(i); |
| 75 } | 75 } |
| 76 ASSERT_TRUE(AwaitQuiescence()); | 76 ASSERT_TRUE(AwaitQuiescence()); |
| 77 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 77 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // TCM ID - 7563874. | 80 // TCM ID - 7563874. |
| 81 IN_PROC_BROWSER_TEST_F(PerformanceLiveExtensionsSyncTest, Add) { | 81 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Add) { |
| 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 82 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 83 | 83 |
| 84 AddExtensions(0, kNumExtensions); | 84 AddExtensions(0, kNumExtensions); |
| 85 base::TimeDelta dt = | 85 base::TimeDelta dt = |
| 86 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 86 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 87 InstallExtensionsPendingForSync(GetProfile(1)); | 87 InstallExtensionsPendingForSync(GetProfile(1)); |
| 88 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 88 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 89 | 89 |
| 90 // TODO(braffert): Compare timings against some target value. | 90 // TODO(braffert): Compare timings against some target value. |
| 91 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | 91 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // TCM ID - 7655397. | 94 // TCM ID - 7655397. |
| 95 IN_PROC_BROWSER_TEST_F(PerformanceLiveExtensionsSyncTest, Update) { | 95 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Update) { |
| 96 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 96 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 97 | 97 |
| 98 AddExtensions(0, kNumExtensions); | 98 AddExtensions(0, kNumExtensions); |
| 99 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 99 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 100 InstallExtensionsPendingForSync(GetProfile(1)); | 100 InstallExtensionsPendingForSync(GetProfile(1)); |
| 101 | 101 |
| 102 UpdateExtensions(0); | 102 UpdateExtensions(0); |
| 103 base::TimeDelta dt = | 103 base::TimeDelta dt = |
| 104 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 104 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 105 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 105 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 106 | 106 |
| 107 // TODO(braffert): Compare timings against some target value. | 107 // TODO(braffert): Compare timings against some target value. |
| 108 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | 108 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; |
| 109 } | 109 } |
| 110 | 110 |
| 111 // TCM ID - 7567721. | 111 // TCM ID - 7567721. |
| 112 IN_PROC_BROWSER_TEST_F(PerformanceLiveExtensionsSyncTest, Delete) { | 112 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, Delete) { |
| 113 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 113 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 114 | 114 |
| 115 AddExtensions(0, kNumExtensions); | 115 AddExtensions(0, kNumExtensions); |
| 116 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 116 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 117 InstallExtensionsPendingForSync(GetProfile(1)); | 117 InstallExtensionsPendingForSync(GetProfile(1)); |
| 118 | 118 |
| 119 RemoveExtensions(0); | 119 RemoveExtensions(0); |
| 120 base::TimeDelta dt = | 120 base::TimeDelta dt = |
| 121 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 121 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 122 ASSERT_TRUE(AllProfilesHaveSameExtensions()); | 122 ASSERT_TRUE(AllProfilesHaveSameExtensions()); |
| 123 | 123 |
| 124 // TODO(braffert): Compare timings against some target value. | 124 // TODO(braffert): Compare timings against some target value. |
| 125 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; | 125 VLOG(0) << std::endl << "dt: " << dt.InSecondsF() << " s"; |
| 126 } | 126 } |
| 127 | 127 |
| 128 IN_PROC_BROWSER_TEST_F(PerformanceLiveExtensionsSyncTest, DISABLED_Benchmark) { | 128 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, DISABLED_Benchmark) { |
| 129 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 129 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 130 | 130 |
| 131 for (int i = 0; i < kNumBenchmarkPoints; ++i) { | 131 for (int i = 0; i < kNumBenchmarkPoints; ++i) { |
| 132 int num_extensions = kBenchmarkPoints[i]; | 132 int num_extensions = kBenchmarkPoints[i]; |
| 133 AddExtensions(0, num_extensions); | 133 AddExtensions(0, num_extensions); |
| 134 base::TimeDelta dt_add = | 134 base::TimeDelta dt_add = |
| 135 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 135 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 136 InstallExtensionsPendingForSync(GetProfile(1)); | 136 InstallExtensionsPendingForSync(GetProfile(1)); |
| 137 VLOG(0) << std::endl << "Add: " << num_extensions << " " | 137 VLOG(0) << std::endl << "Add: " << num_extensions << " " |
| 138 << dt_add.InSecondsF(); | 138 << dt_add.InSecondsF(); |
| 139 | 139 |
| 140 UpdateExtensions(0); | 140 UpdateExtensions(0); |
| 141 base::TimeDelta dt_update = | 141 base::TimeDelta dt_update = |
| 142 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 142 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 143 VLOG(0) << std::endl << "Update: " << num_extensions << " " | 143 VLOG(0) << std::endl << "Update: " << num_extensions << " " |
| 144 << dt_update.InSecondsF(); | 144 << dt_update.InSecondsF(); |
| 145 | 145 |
| 146 RemoveExtensions(0); | 146 RemoveExtensions(0); |
| 147 base::TimeDelta dt_delete = | 147 base::TimeDelta dt_delete = |
| 148 LiveSyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 148 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
| 149 VLOG(0) << std::endl << "Delete: " << num_extensions << " " | 149 VLOG(0) << std::endl << "Delete: " << num_extensions << " " |
| 150 << dt_delete.InSecondsF(); | 150 << dt_delete.InSecondsF(); |
| 151 | 151 |
| 152 Cleanup(); | 152 Cleanup(); |
| 153 } | 153 } |
| 154 } | 154 } |
| OLD | NEW |