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/memory/shared_memory.h" | 5 #include "base/memory/shared_memory.h" |
6 #include "base/metrics/stats_counters.h" | 6 #include "base/metrics/stats_counters.h" |
7 #include "base/metrics/stats_table.h" | 7 #include "base/metrics/stats_table.h" |
8 #include "base/process/kill.h" | 8 #include "base/process/kill.h" |
9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (id_ % 2) | 94 if (id_ % 2) |
95 mixed_counter.Decrement(); | 95 mixed_counter.Decrement(); |
96 else | 96 else |
97 mixed_counter.Increment(); | 97 mixed_counter.Increment(); |
98 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); | 98 PlatformThread::Sleep(TimeDelta::FromMilliseconds(index % 10)); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 // Create a few threads and have them poke on their counters. | 102 // Create a few threads and have them poke on their counters. |
103 // See http://crbug.com/10611 for more information. | 103 // See http://crbug.com/10611 for more information. |
104 #if defined(OS_MACOSX) || defined(THREAD_SANITIZER) | 104 // It is disabled on Win x64 incremental linking pending resolution of |
| 105 // http://crbug.com/251251. |
| 106 #if defined(OS_MACOSX) || defined(THREAD_SANITIZER) || \ |
| 107 (defined(OS_WIN) && defined(ARCH_CPU_X86_64) && \ |
| 108 defined(INCREMENTAL_LINKING)) |
105 #define MAYBE_MultipleThreads DISABLED_MultipleThreads | 109 #define MAYBE_MultipleThreads DISABLED_MultipleThreads |
106 #else | 110 #else |
107 #define MAYBE_MultipleThreads MultipleThreads | 111 #define MAYBE_MultipleThreads MultipleThreads |
108 #endif | 112 #endif |
109 TEST_F(StatsTableTest, MAYBE_MultipleThreads) { | 113 TEST_F(StatsTableTest, MAYBE_MultipleThreads) { |
110 // Create a stats table. | 114 // Create a stats table. |
111 const int kMaxThreads = 20; | 115 const int kMaxThreads = 20; |
112 const int kMaxCounter = 5; | 116 const int kMaxCounter = 5; |
113 StatsTable table(StatsTable::TableIdentifier(), kMaxThreads, kMaxCounter); | 117 StatsTable table(StatsTable::TableIdentifier(), kMaxThreads, kMaxCounter); |
114 StatsTable::set_current(&table); | 118 StatsTable::set_current(&table); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 StatsScope<StatsCounterTimer> timer(foo); | 393 StatsScope<StatsCounterTimer> timer(foo); |
390 StatsScope<StatsRate> timer2(bar); | 394 StatsScope<StatsRate> timer2(bar); |
391 PlatformThread::Sleep(kDuration); | 395 PlatformThread::Sleep(kDuration); |
392 } | 396 } |
393 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); | 397 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); |
394 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); | 398 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); |
395 EXPECT_EQ(2, table.GetCounterValue("c:bar")); | 399 EXPECT_EQ(2, table.GetCounterValue("c:bar")); |
396 } | 400 } |
397 | 401 |
398 } // namespace base | 402 } // namespace base |
OLD | NEW |