Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: base/metrics/stats_table_unittest.cc

Issue 9463018: Improve SharedMemory::Lock on Posix and reenable StatsTableTest.MultipleThreads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/shared_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Flaky, http://crbug.com/10611. 109 TEST_F(StatsTableTest, MultipleThreads) {
110 TEST_F(StatsTableTest, DISABLED_MultipleThreads) {
111 // Create a stats table. 110 // Create a stats table.
112 const std::string kTableName = "MultipleThreadStatTable"; 111 const std::string kTableName = "MultipleThreadStatTable";
113 const int kMaxThreads = 20; 112 const int kMaxThreads = 20;
114 const int kMaxCounter = 5; 113 const int kMaxCounter = 5;
115 DeleteShmem(kTableName); 114 DeleteShmem(kTableName);
116 StatsTable table(kTableName, kMaxThreads, kMaxCounter); 115 StatsTable table(kTableName, kMaxThreads, kMaxCounter);
117 StatsTable::set_current(&table); 116 StatsTable::set_current(&table);
118 117
119 EXPECT_EQ(0, table.CountThreadsRegistered()); 118 EXPECT_EQ(0, table.CountThreadsRegistered());
120 119
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 PlatformThread::Sleep(kDuration); 401 PlatformThread::Sleep(kDuration);
403 } 402 }
404 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo")); 403 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:foo"));
405 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar")); 404 EXPECT_LE(kDuration.InMilliseconds() * 2, table.GetCounterValue("t:bar"));
406 EXPECT_EQ(2, table.GetCounterValue("c:bar")); 405 EXPECT_EQ(2, table.GetCounterValue("c:bar"));
407 406
408 DeleteShmem(kTableName); 407 DeleteShmem(kTableName);
409 } 408 }
410 409
411 } // namespace base 410 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698