OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 name = "c:" + kCounterMixed; | 164 name = "c:" + kCounterMixed; |
165 EXPECT_EQ((kMaxThreads % 2) * kThreadLoops, | 165 EXPECT_EQ((kMaxThreads % 2) * kThreadLoops, |
166 table.GetCounterValue(name)); | 166 table.GetCounterValue(name)); |
167 EXPECT_EQ(0, table.CountThreadsRegistered()); | 167 EXPECT_EQ(0, table.CountThreadsRegistered()); |
168 | 168 |
169 DeleteShmem(kTableName); | 169 DeleteShmem(kTableName); |
170 } | 170 } |
171 | 171 |
172 const std::string kMPTableName = "MultipleProcessStatTable"; | 172 const std::string kMPTableName = "MultipleProcessStatTable"; |
173 | 173 |
174 MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { | 174 MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain, NULL) { |
175 // Each process will open the shared memory and set counters | 175 // Each process will open the shared memory and set counters |
176 // concurrently in a loop. We'll use some pauses to | 176 // concurrently in a loop. We'll use some pauses to |
177 // mixup the scheduling. | 177 // mixup the scheduling. |
178 | 178 |
179 StatsTable table(kMPTableName, 0, 0); | 179 StatsTable table(kMPTableName, 0, 0); |
180 StatsTable::set_current(&table); | 180 StatsTable::set_current(&table); |
181 StatsCounter zero_counter(kCounterZero); | 181 StatsCounter zero_counter(kCounterZero); |
182 StatsCounter lucky13_counter(kCounter1313); | 182 StatsCounter lucky13_counter(kCounter1313); |
183 StatsCounter increment_counter(kCounterIncrement); | 183 StatsCounter increment_counter(kCounterIncrement); |
184 StatsCounter decrement_counter(kCounterDecrement); | 184 StatsCounter decrement_counter(kCounterDecrement); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 PlatformThread::Sleep(kDuration); | 413 PlatformThread::Sleep(kDuration); |
414 } | 414 } |
415 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); | 415 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
416 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); | 416 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
417 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 417 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
418 | 418 |
419 DeleteShmem(kTableName); | 419 DeleteShmem(kTableName); |
420 } | 420 } |
421 | 421 |
422 } // namespace base | 422 } // namespace base |
OLD | NEW |