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

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

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

Powered by Google App Engine
This is Rietveld 408576698