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/extensions_helper.h" |
| 8 #include "chrome/test/live_sync/live_sync_test.h" |
8 #include "chrome/test/live_sync/performance/sync_timing_helper.h" | 9 #include "chrome/test/live_sync/performance/sync_timing_helper.h" |
9 | 10 |
| 11 using extensions_helper::AllProfilesHaveSameExtensions; |
| 12 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier; |
| 13 using extensions_helper::DisableExtension; |
| 14 using extensions_helper::EnableExtension; |
| 15 using extensions_helper::GetInstalledExtensions; |
| 16 using extensions_helper::InstallExtension; |
| 17 using extensions_helper::InstallExtensionsPendingForSync; |
| 18 using extensions_helper::IsExtensionEnabled; |
| 19 using extensions_helper::UninstallExtension; |
| 20 |
10 // TODO(braffert): Replicate these tests for apps. | 21 // TODO(braffert): Replicate these tests for apps. |
11 | 22 |
12 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all | 23 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all |
13 // datatypes into a performance test base class, once it is possible to do so. | 24 // datatypes into a performance test base class, once it is possible to do so. |
14 static const int kNumExtensions = 150; | 25 static const int kNumExtensions = 150; |
15 static const int kNumBenchmarkPoints = 18; | 26 static const int kNumBenchmarkPoints = 18; |
16 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, | 27 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125, |
17 150, 175, 200, 225, 250, 300, 350, 400, | 28 150, 175, 200, 225, 250, 300, 350, 400, |
18 500}; | 29 500}; |
19 | 30 |
20 class ExtensionsSyncPerfTest : public TwoClientLiveExtensionsSyncTest { | 31 class ExtensionsSyncPerfTest : public LiveSyncTest { |
21 public: | 32 public: |
22 ExtensionsSyncPerfTest() : extension_number_(0) {} | 33 ExtensionsSyncPerfTest() |
| 34 : LiveSyncTest(TWO_CLIENT), |
| 35 extension_number_(0) {} |
23 | 36 |
24 // Adds |num_extensions| new unique extensions to |profile|. | 37 // Adds |num_extensions| new unique extensions to |profile|. |
25 void AddExtensions(int profile, int num_extensions); | 38 void AddExtensions(int profile, int num_extensions); |
26 | 39 |
27 // Updates the enabled/disabled state for all extensions in |profile|. | 40 // Updates the enabled/disabled state for all extensions in |profile|. |
28 void UpdateExtensions(int profile); | 41 void UpdateExtensions(int profile); |
29 | 42 |
30 // Uninstalls all currently installed extensions from |profile|. | 43 // Uninstalls all currently installed extensions from |profile|. |
31 void RemoveExtensions(int profile); | 44 void RemoveExtensions(int profile); |
32 | 45 |
33 // Returns the number of currently installed extensions for |profile|. | 46 // Returns the number of currently installed extensions for |profile|. |
34 int GetExtensionCount(int profile); | 47 int GetExtensionCount(int profile); |
35 | 48 |
36 // Uninstalls all extensions from all profiles. Called between benchmark | 49 // Uninstalls all extensions from all profiles. Called between benchmark |
37 // iterations. | 50 // iterations. |
38 void Cleanup(); | 51 void Cleanup(); |
39 | 52 |
40 private: | 53 private: |
41 int extension_number_; | 54 int extension_number_; |
42 DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest); | 55 DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest); |
43 }; | 56 }; |
44 | 57 |
45 void ExtensionsSyncPerfTest::AddExtensions(int profile, | 58 void ExtensionsSyncPerfTest::AddExtensions(int profile, int num_extensions) { |
46 int num_extensions) { | |
47 for (int i = 0; i < num_extensions; ++i) { | 59 for (int i = 0; i < num_extensions; ++i) { |
48 InstallExtension(GetProfile(profile), extension_number_++); | 60 InstallExtension(GetProfile(profile), extension_number_++); |
49 } | 61 } |
50 } | 62 } |
51 | 63 |
52 void ExtensionsSyncPerfTest::UpdateExtensions(int profile) { | 64 void ExtensionsSyncPerfTest::UpdateExtensions(int profile) { |
53 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); | 65 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); |
54 for (std::vector<int>::iterator it = extensions.begin(); | 66 for (std::vector<int>::iterator it = extensions.begin(); |
55 it != extensions.end(); ++it) { | 67 it != extensions.end(); ++it) { |
56 if (IsExtensionEnabled(GetProfile(profile), *it)) { | 68 if (IsExtensionEnabled(GetProfile(profile), *it)) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 139 |
128 RemoveExtensions(0); | 140 RemoveExtensions(0); |
129 base::TimeDelta dt_delete = | 141 base::TimeDelta dt_delete = |
130 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); | 142 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); |
131 VLOG(0) << std::endl << "Delete: " << num_extensions << " " | 143 VLOG(0) << std::endl << "Delete: " << num_extensions << " " |
132 << dt_delete.InSecondsF(); | 144 << dt_delete.InSecondsF(); |
133 | 145 |
134 Cleanup(); | 146 Cleanup(); |
135 } | 147 } |
136 } | 148 } |
OLD | NEW |