Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: chrome/test/live_sync/performance/extensions_sync_perf_test.cc

Issue 7491062: Sync performance test: Remove disabled benchmark tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions_helper.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/live_sync_test.h"
9 #include "chrome/test/live_sync/performance/sync_timing_helper.h" 9 #include "chrome/test/live_sync/performance/sync_timing_helper.h"
10 10
11 using extensions_helper::AllProfilesHaveSameExtensions; 11 using extensions_helper::AllProfilesHaveSameExtensions;
12 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier; 12 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier;
13 using extensions_helper::DisableExtension; 13 using extensions_helper::DisableExtension;
14 using extensions_helper::EnableExtension; 14 using extensions_helper::EnableExtension;
15 using extensions_helper::GetInstalledExtensions; 15 using extensions_helper::GetInstalledExtensions;
16 using extensions_helper::InstallExtension; 16 using extensions_helper::InstallExtension;
17 using extensions_helper::InstallExtensionsPendingForSync; 17 using extensions_helper::InstallExtensionsPendingForSync;
18 using extensions_helper::IsExtensionEnabled; 18 using extensions_helper::IsExtensionEnabled;
19 using extensions_helper::UninstallExtension; 19 using extensions_helper::UninstallExtension;
20 20
21 // TODO(braffert): Replicate these tests for apps. 21 // TODO(braffert): Replicate these tests for apps.
22 22
23 // TODO(braffert): Move kNumBenchmarkPoints and kBenchmarkPoints for all
24 // datatypes into a performance test base class, once it is possible to do so.
25 static const int kNumExtensions = 150; 23 static const int kNumExtensions = 150;
26 static const int kNumBenchmarkPoints = 18;
27 static const int kBenchmarkPoints[] = {1, 10, 20, 30, 40, 50, 75, 100, 125,
28 150, 175, 200, 225, 250, 300, 350, 400,
29 500};
30 24
31 class ExtensionsSyncPerfTest : public LiveSyncTest { 25 class ExtensionsSyncPerfTest : public LiveSyncTest {
32 public: 26 public:
33 ExtensionsSyncPerfTest() 27 ExtensionsSyncPerfTest()
34 : LiveSyncTest(TWO_CLIENT), 28 : LiveSyncTest(TWO_CLIENT),
35 extension_number_(0) {} 29 extension_number_(0) {}
36 30
37 // Adds |num_extensions| new unique extensions to |profile|. 31 // Adds |num_extensions| new unique extensions to |profile|.
38 void AddExtensions(int profile, int num_extensions); 32 void AddExtensions(int profile, int num_extensions);
39 33
40 // Updates the enabled/disabled state for all extensions in |profile|. 34 // Updates the enabled/disabled state for all extensions in |profile|.
41 void UpdateExtensions(int profile); 35 void UpdateExtensions(int profile);
42 36
43 // Uninstalls all currently installed extensions from |profile|. 37 // Uninstalls all currently installed extensions from |profile|.
44 void RemoveExtensions(int profile); 38 void RemoveExtensions(int profile);
45 39
46 // Returns the number of currently installed extensions for |profile|. 40 // Returns the number of currently installed extensions for |profile|.
47 int GetExtensionCount(int profile); 41 int GetExtensionCount(int profile);
48 42
49 // Uninstalls all extensions from all profiles. Called between benchmark
50 // iterations.
51 void Cleanup();
52
53 private: 43 private:
54 int extension_number_; 44 int extension_number_;
55 DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest); 45 DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest);
56 }; 46 };
57 47
58 void ExtensionsSyncPerfTest::AddExtensions(int profile, int num_extensions) { 48 void ExtensionsSyncPerfTest::AddExtensions(int profile, int num_extensions) {
59 for (int i = 0; i < num_extensions; ++i) { 49 for (int i = 0; i < num_extensions; ++i) {
60 InstallExtension(GetProfile(profile), extension_number_++); 50 InstallExtension(GetProfile(profile), extension_number_++);
61 } 51 }
62 } 52 }
(...skipping 15 matching lines...) Expand all
78 } 68 }
79 69
80 void ExtensionsSyncPerfTest::RemoveExtensions(int profile) { 70 void ExtensionsSyncPerfTest::RemoveExtensions(int profile) {
81 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile)); 71 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile));
82 for (std::vector<int>::iterator it = extensions.begin(); 72 for (std::vector<int>::iterator it = extensions.begin();
83 it != extensions.end(); ++it) { 73 it != extensions.end(); ++it) {
84 UninstallExtension(GetProfile(profile), *it); 74 UninstallExtension(GetProfile(profile), *it);
85 } 75 }
86 } 76 }
87 77
88 void ExtensionsSyncPerfTest::Cleanup() {
89 for (int i = 0; i < num_clients(); ++i) {
90 RemoveExtensions(i);
91 }
92 ASSERT_TRUE(AwaitQuiescence());
93 ASSERT_TRUE(AllProfilesHaveSameExtensions());
94 }
95
96 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, P0) { 78 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, P0) {
97 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 79 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
98 int num_default_extensions = GetExtensionCount(0); 80 int num_default_extensions = GetExtensionCount(0);
99 int expected_extension_count = num_default_extensions + kNumExtensions; 81 int expected_extension_count = num_default_extensions + kNumExtensions;
100 82
101 // TCM ID - 7563874. 83 // TCM ID - 7563874.
102 AddExtensions(0, kNumExtensions); 84 AddExtensions(0, kNumExtensions);
103 base::TimeDelta dt = 85 base::TimeDelta dt =
104 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 86 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
105 InstallExtensionsPendingForSync(GetProfile(1)); 87 InstallExtensionsPendingForSync(GetProfile(1));
106 ASSERT_EQ(expected_extension_count, GetExtensionCount(1)); 88 ASSERT_EQ(expected_extension_count, GetExtensionCount(1));
107 SyncTimingHelper::PrintResult("extensions", "add_extensions", dt); 89 SyncTimingHelper::PrintResult("extensions", "add_extensions", dt);
108 90
109 // TCM ID - 7655397. 91 // TCM ID - 7655397.
110 UpdateExtensions(0); 92 UpdateExtensions(0);
111 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 93 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
112 ASSERT_EQ(expected_extension_count, GetExtensionCount(1)); 94 ASSERT_EQ(expected_extension_count, GetExtensionCount(1));
113 SyncTimingHelper::PrintResult("extensions", "update_extensions", dt); 95 SyncTimingHelper::PrintResult("extensions", "update_extensions", dt);
114 96
115 // TCM ID - 7567721. 97 // TCM ID - 7567721.
116 RemoveExtensions(0); 98 RemoveExtensions(0);
117 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 99 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
118 ASSERT_EQ(num_default_extensions, GetExtensionCount(1)); 100 ASSERT_EQ(num_default_extensions, GetExtensionCount(1));
119 SyncTimingHelper::PrintResult("extensions", "delete_extensions", dt); 101 SyncTimingHelper::PrintResult("extensions", "delete_extensions", dt);
120 } 102 }
121
122 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, DISABLED_Benchmark) {
123 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
124
125 for (int i = 0; i < kNumBenchmarkPoints; ++i) {
126 int num_extensions = kBenchmarkPoints[i];
127 AddExtensions(0, num_extensions);
128 base::TimeDelta dt_add =
129 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
130 InstallExtensionsPendingForSync(GetProfile(1));
131 VLOG(0) << std::endl << "Add: " << num_extensions << " "
132 << dt_add.InSecondsF();
133
134 UpdateExtensions(0);
135 base::TimeDelta dt_update =
136 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
137 VLOG(0) << std::endl << "Update: " << num_extensions << " "
138 << dt_update.InSecondsF();
139
140 RemoveExtensions(0);
141 base::TimeDelta dt_delete =
142 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
143 VLOG(0) << std::endl << "Delete: " << num_extensions << " "
144 << dt_delete.InSecondsF();
145
146 Cleanup();
147 }
148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698