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

Side by Side Diff: base/profiler/tracked_time_unittest.cc

Issue 1104053004: Cleanup: removing unused descendants information from tracked objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: isherman@ comments Created 5 years, 7 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/profiler/scoped_profile.cc ('k') | base/threading/sequenced_worker_pool.cc » ('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 // Test of classes in tracked_time.cc 5 // Test of classes in tracked_time.cc
6 6
7 #include "base/profiler/tracked_time.h" 7 #include "base/profiler/tracked_time.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/tracked_objects.h" 9 #include "base/tracked_objects.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Check to be sure disabling the collection of data induces a null time 71 // Check to be sure disabling the collection of data induces a null time
72 // (which we know will return much faster). 72 // (which we know will return much faster).
73 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) 73 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED))
74 return; 74 return;
75 // Since we disabled tracking, we should get a null response. 75 // Since we disabled tracking, we should get a null response.
76 TrackedTime track_now = ThreadData::Now(); 76 TrackedTime track_now = ThreadData::Now();
77 EXPECT_TRUE(track_now.is_null()); 77 EXPECT_TRUE(track_now.is_null());
78 } 78 }
79 79
80 TEST(TrackedTimeTest, TrackedTimerEnabled) { 80 TEST(TrackedTimeTest, TrackedTimerEnabled) {
81 if (!ThreadData::InitializeAndSetTrackingStatus( 81 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::PROFILING_ACTIVE))
82 ThreadData::PROFILING_CHILDREN_ACTIVE))
83 return; 82 return;
84 // Make sure that when we enable tracking, we get a real timer result. 83 // Make sure that when we enable tracking, we get a real timer result.
85 84
86 // First get a 64 bit timer (which should not be null). 85 // First get a 64 bit timer (which should not be null).
87 base::TimeTicks ticks_before = base::TimeTicks::Now(); 86 base::TimeTicks ticks_before = base::TimeTicks::Now();
88 EXPECT_FALSE(ticks_before.is_null()); 87 EXPECT_FALSE(ticks_before.is_null());
89 88
90 // Then get a 32 bit timer that can be null when it wraps. 89 // Then get a 32 bit timer that can be null when it wraps.
91 // Crtical difference from the TrackedTimerVsTimeTicks test, is that we use 90 // Crtical difference from the TrackedTimerVsTimeTicks test, is that we use
92 // ThreadData::Now(). It can sometimes return the null time. 91 // ThreadData::Now(). It can sometimes return the null time.
93 TrackedTime now = ThreadData::Now(); 92 TrackedTime now = ThreadData::Now();
94 93
95 // Then get a bracketing time. 94 // Then get a bracketing time.
96 base::TimeTicks ticks_after = base::TimeTicks::Now(); 95 base::TimeTicks ticks_after = base::TimeTicks::Now();
97 EXPECT_FALSE(ticks_after.is_null()); 96 EXPECT_FALSE(ticks_after.is_null());
98 97
99 // Now make sure that we bracketed our tracked time nicely. 98 // Now make sure that we bracketed our tracked time nicely.
100 Duration before = now - TrackedTime(ticks_before); 99 Duration before = now - TrackedTime(ticks_before);
101 EXPECT_LE(0, before.InMilliseconds()); 100 EXPECT_LE(0, before.InMilliseconds());
102 Duration after = now - TrackedTime(ticks_after); 101 Duration after = now - TrackedTime(ticks_after);
103 EXPECT_GE(0, after.InMilliseconds()); 102 EXPECT_GE(0, after.InMilliseconds());
104 } 103 }
105 104
106 } // namespace tracked_objects 105 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/profiler/scoped_profile.cc ('k') | base/threading/sequenced_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698