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

Side by Side Diff: base/debug/activity_tracker_unittest.cc

Issue 2255503002: New cache for the activity tracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed comment Created 4 years, 3 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
« no previous file with comments | « base/debug/activity_tracker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/debug/activity_tracker.h" 5 #include "base/debug/activity_tracker.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/memory_mapped_file.h" 12 #include "base/files/memory_mapped_file.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/pending_task.h" 15 #include "base/pending_task.h"
16 #include "base/rand_util.h"
16 #include "base/synchronization/condition_variable.h" 17 #include "base/synchronization/condition_variable.h"
17 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
18 #include "base/synchronization/spin_wait.h" 19 #include "base/synchronization/spin_wait.h"
20 #include "base/threading/platform_thread.h"
19 #include "base/threading/simple_thread.h" 21 #include "base/threading/simple_thread.h"
20 #include "base/time/time.h" 22 #include "base/time/time.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 24
23 namespace base { 25 namespace base {
24 namespace debug { 26 namespace debug {
25 27
26 namespace { 28 namespace {
27 29
28 class TestActivityTracker : public ThreadActivityTracker { 30 class TestActivityTracker : public ThreadActivityTracker {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (!global_tracker) 67 if (!global_tracker)
66 return 0; 68 return 0;
67 return global_tracker->thread_tracker_count_.load( 69 return global_tracker->thread_tracker_count_.load(
68 std::memory_order_relaxed); 70 std::memory_order_relaxed);
69 } 71 }
70 72
71 size_t GetGlobalInactiveTrackerCount() { 73 size_t GetGlobalInactiveTrackerCount() {
72 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get(); 74 GlobalActivityTracker* global_tracker = GlobalActivityTracker::Get();
73 if (!global_tracker) 75 if (!global_tracker)
74 return 0; 76 return 0;
75 return global_tracker->available_memories_count_.load( 77 return global_tracker->available_memories_.used();
76 std::memory_order_relaxed);
77 } 78 }
78 79
79 static void DoNothing() {} 80 static void DoNothing() {}
80 }; 81 };
81 82
82 TEST_F(ActivityTrackerTest, PushPopTest) { 83 TEST_F(ActivityTrackerTest, PushPopTest) {
83 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker(); 84 std::unique_ptr<ThreadActivityTracker> tracker = CreateActivityTracker();
84 ActivitySnapshot snapshot; 85 ActivitySnapshot snapshot;
85 86
86 ASSERT_TRUE(tracker->Snapshot(&snapshot)); 87 ASSERT_TRUE(tracker->Snapshot(&snapshot));
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 EXPECT_EQ(starting_inactive, GetGlobalInactiveTrackerCount()); 281 EXPECT_EQ(starting_inactive, GetGlobalInactiveTrackerCount());
281 282
282 t2.Exit(); 283 t2.Exit();
283 t2.Join(); 284 t2.Join();
284 EXPECT_EQ(starting_active, GetGlobalActiveTrackerCount()); 285 EXPECT_EQ(starting_active, GetGlobalActiveTrackerCount());
285 EXPECT_EQ(starting_inactive + 1, GetGlobalInactiveTrackerCount()); 286 EXPECT_EQ(starting_inactive + 1, GetGlobalInactiveTrackerCount());
286 } 287 }
287 288
288 } // namespace debug 289 } // namespace debug
289 } // namespace base 290 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/activity_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698