| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 decrement_counter.Decrement(); | 99 decrement_counter.Decrement(); |
| 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 TEST_F(StatsTableTest, MultipleThreads) { | 109 // See http://crbug.com/10611 for more information. |
| 110 #if defined(OS_MACOSX) |
| 111 #define MAYBE_MultipleThreads DISABLED_MultipleThreads |
| 112 #else |
| 113 #define MAYBE_MultipleThreads MultipleThreads |
| 114 #endif |
| 115 TEST_F(StatsTableTest, MAYBE_MultipleThreads) { |
| 110 // Create a stats table. | 116 // Create a stats table. |
| 111 const std::string kTableName = "MultipleThreadStatTable"; | 117 const std::string kTableName = "MultipleThreadStatTable"; |
| 112 const int kMaxThreads = 20; | 118 const int kMaxThreads = 20; |
| 113 const int kMaxCounter = 5; | 119 const int kMaxCounter = 5; |
| 114 DeleteShmem(kTableName); | 120 DeleteShmem(kTableName); |
| 115 StatsTable table(kTableName, kMaxThreads, kMaxCounter); | 121 StatsTable table(kTableName, kMaxThreads, kMaxCounter); |
| 116 StatsTable::set_current(&table); | 122 StatsTable::set_current(&table); |
| 117 | 123 |
| 118 EXPECT_EQ(0, table.CountThreadsRegistered()); | 124 EXPECT_EQ(0, table.CountThreadsRegistered()); |
| 119 | 125 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 PlatformThread::Sleep(kDuration); | 407 PlatformThread::Sleep(kDuration); |
| 402 } | 408 } |
| 403 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); | 409 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
| 404 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); | 410 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
| 405 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 411 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
| 406 | 412 |
| 407 DeleteShmem(kTableName); | 413 DeleteShmem(kTableName); |
| 408 } | 414 } |
| 409 | 415 |
| 410 } // namespace base | 416 } // namespace base |
| OLD | NEW |