| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (id_ % 2) | 102 if (id_ % 2) |
| 103 mixed_counter.Decrement(); | 103 mixed_counter.Decrement(); |
| 104 else | 104 else |
| 105 mixed_counter.Increment(); | 105 mixed_counter.Increment(); |
| 106 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); | 106 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Create a few threads and have them poke on their counters. | 110 // Create a few threads and have them poke on their counters. |
| 111 // See http://crbug.com/10611 for more information. | 111 // See http://crbug.com/10611 for more information. |
| 112 #if defined(OS_MACOSX) | 112 #if defined(OS_MACOSX) || defined(THREAD_SANITIZER) |
| 113 #define MAYBE_MultipleThreads DISABLED_MultipleThreads | 113 #define MAYBE_MultipleThreads DISABLED_MultipleThreads |
| 114 #else | 114 #else |
| 115 #define MAYBE_MultipleThreads MultipleThreads | 115 #define MAYBE_MultipleThreads MultipleThreads |
| 116 #endif | 116 #endif |
| 117 TEST_F(StatsTableTest, MAYBE_MultipleThreads) { | 117 TEST_F(StatsTableTest, MAYBE_MultipleThreads) { |
| 118 // Create a stats table. | 118 // Create a stats table. |
| 119 const std::string kTableName = "MultipleThreadStatTable"; | 119 const std::string kTableName = "MultipleThreadStatTable"; |
| 120 const int kMaxThreads = 20; | 120 const int kMaxThreads = 20; |
| 121 const int kMaxCounter = 5; | 121 const int kMaxCounter = 5; |
| 122 DeleteShmem(kTableName); | 122 DeleteShmem(kTableName); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 PlatformThread::Sleep(kDuration); | 414 PlatformThread::Sleep(kDuration); |
| 415 } | 415 } |
| 416 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); | 416 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
| 417 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); | 417 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
| 418 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 418 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
| 419 | 419 |
| 420 DeleteShmem(kTableName); | 420 DeleteShmem(kTableName); |
| 421 } | 421 } |
| 422 | 422 |
| 423 } // namespace base | 423 } // namespace base |
| OLD | NEW |