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/metrics/stats_counters.h" | 5 #include "base/metrics/stats_counters.h" |
6 #include "base/metrics/stats_table.h" | 6 #include "base/metrics/stats_table.h" |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "base/test/multiprocess_test.h" | 10 #include "base/test/multiprocess_test.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 if (id_ % 2) | 100 if (id_ % 2) |
101 mixed_counter.Decrement(); | 101 mixed_counter.Decrement(); |
102 else | 102 else |
103 mixed_counter.Increment(); | 103 mixed_counter.Increment(); |
104 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); | 104 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 // Create a few threads and have them poke on their counters. | 108 // Create a few threads and have them poke on their counters. |
109 // Flaky, http://crbug.com/10611. | 109 // Flaky, http://crbug.com/10611. |
110 TEST_F(StatsTableTest, FLAKY_MultipleThreads) { | 110 TEST_F(StatsTableTest, DISABLED_MultipleThreads) { |
111 // Create a stats table. | 111 // Create a stats table. |
112 const std::string kTableName = "MultipleThreadStatTable"; | 112 const std::string kTableName = "MultipleThreadStatTable"; |
113 const int kMaxThreads = 20; | 113 const int kMaxThreads = 20; |
114 const int kMaxCounter = 5; | 114 const int kMaxCounter = 5; |
115 DeleteShmem(kTableName); | 115 DeleteShmem(kTableName); |
116 StatsTable table(kTableName, kMaxThreads, kMaxCounter); | 116 StatsTable table(kTableName, kMaxThreads, kMaxCounter); |
117 StatsTable::set_current(&table); | 117 StatsTable::set_current(&table); |
118 | 118 |
119 EXPECT_EQ(0, table.CountThreadsRegistered()); | 119 EXPECT_EQ(0, table.CountThreadsRegistered()); |
120 | 120 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 lucky13_counter.Set(1313); | 180 lucky13_counter.Set(1313); |
181 increment_counter.Increment(); | 181 increment_counter.Increment(); |
182 decrement_counter.Decrement(); | 182 decrement_counter.Decrement(); |
183 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); | 183 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); |
184 } | 184 } |
185 return 0; | 185 return 0; |
186 } | 186 } |
187 | 187 |
188 // Create a few processes and have them poke on their counters. | 188 // Create a few processes and have them poke on their counters. |
189 // This test is slow and flaky http://crbug.com/10611 | 189 // This test is slow and flaky http://crbug.com/10611 |
190 TEST_F(StatsTableTest, FLAKY_MultipleProcesses) { | 190 TEST_F(StatsTableTest, DISABLED_MultipleProcesses) { |
191 // Create a stats table. | 191 // Create a stats table. |
192 const int kMaxProcs = 20; | 192 const int kMaxProcs = 20; |
193 const int kMaxCounter = 5; | 193 const int kMaxCounter = 5; |
194 DeleteShmem(kMPTableName); | 194 DeleteShmem(kMPTableName); |
195 StatsTable table(kMPTableName, kMaxProcs, kMaxCounter); | 195 StatsTable table(kMPTableName, kMaxProcs, kMaxCounter); |
196 StatsTable::set_current(&table); | 196 StatsTable::set_current(&table); |
197 EXPECT_EQ(0, table.CountThreadsRegistered()); | 197 EXPECT_EQ(0, table.CountThreadsRegistered()); |
198 | 198 |
199 // Spin up a set of processes to go bang on the various counters. | 199 // Spin up a set of processes to go bang on the various counters. |
200 // After we join the processes, we'll make sure the counters | 200 // After we join the processes, we'll make sure the counters |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 PlatformThread::Sleep(kDuration); | 402 PlatformThread::Sleep(kDuration); |
403 } | 403 } |
404 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); | 404 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
405 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); | 405 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
406 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 406 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
407 | 407 |
408 DeleteShmem(kTableName); | 408 DeleteShmem(kTableName); |
409 } | 409 } |
410 | 410 |
411 } // namespace base | 411 } // namespace base |
OLD | NEW |