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

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

Issue 9348028: Revert 120789 - Propogate status setting for profiler to track parents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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/tracked_objects.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) 2011 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.h" 8 #include "base/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"
11 11
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Now make sure that we bracketed our tracked time nicely. 69 // Now make sure that we bracketed our tracked time nicely.
70 Duration before = now - TrackedTime(ticks_before); 70 Duration before = now - TrackedTime(ticks_before);
71 EXPECT_LE(0, before.InMilliseconds()); 71 EXPECT_LE(0, before.InMilliseconds());
72 Duration after = now - TrackedTime(ticks_after); 72 Duration after = now - TrackedTime(ticks_after);
73 EXPECT_GE(0, after.InMilliseconds()); 73 EXPECT_GE(0, after.InMilliseconds());
74 } 74 }
75 75
76 TEST(TrackedTimeTest, TrackedTimerDisabled) { 76 TEST(TrackedTimeTest, TrackedTimerDisabled) {
77 // Check to be sure disabling the collection of data induces a null time 77 // Check to be sure disabling the collection of data induces a null time
78 // (which we know will return much faster). 78 // (which we know will return much faster).
79 if (!ThreadData::InitializeAndSetTrackingStatus(ThreadData::DEACTIVATED)) 79 if (!ThreadData::InitializeAndSetTrackingStatus(false))
80 return; 80 return;
81 // Since we disabled tracking, we should get a null response. 81 // Since we disabled tracking, we should get a null response.
82 TrackedTime track_now = ThreadData::Now(); 82 TrackedTime track_now = ThreadData::Now();
83 EXPECT_TRUE(track_now.is_null()); 83 EXPECT_TRUE(track_now.is_null());
84 track_now = ThreadData::NowForStartOfRun(NULL); 84 track_now = ThreadData::NowForStartOfRun(NULL);
85 EXPECT_TRUE(track_now.is_null()); 85 EXPECT_TRUE(track_now.is_null());
86 track_now = ThreadData::NowForEndOfRun(); 86 track_now = ThreadData::NowForEndOfRun();
87 EXPECT_TRUE(track_now.is_null()); 87 EXPECT_TRUE(track_now.is_null());
88 } 88 }
89 89
90 TEST(TrackedTimeTest, TrackedTimerEnabled) { 90 TEST(TrackedTimeTest, TrackedTimerEnabled) {
91 if (!ThreadData::InitializeAndSetTrackingStatus( 91 if (!ThreadData::InitializeAndSetTrackingStatus(true))
92 ThreadData::PROFILING_CHILDREN_ACTIVE))
93 return; 92 return;
94 // Make sure that when we enable tracking, we get a real timer result. 93 // Make sure that when we enable tracking, we get a real timer result.
95 94
96 // First get a 64 bit timer (which should not be null). 95 // First get a 64 bit timer (which should not be null).
97 base::TimeTicks ticks_before = base::TimeTicks::Now(); 96 base::TimeTicks ticks_before = base::TimeTicks::Now();
98 EXPECT_FALSE(ticks_before.is_null()); 97 EXPECT_FALSE(ticks_before.is_null());
99 98
100 // Then get a 32 bit timer that can be null when it wraps. 99 // Then get a 32 bit timer that can be null when it wraps.
101 // Crtical difference from the TrackedTimerVsTimeTicks test, is that we use 100 // Crtical difference from the TrackedTimerVsTimeTicks test, is that we use
102 // ThreadData::Now(). It can sometimes return the null time. 101 // ThreadData::Now(). It can sometimes return the null time.
103 TrackedTime now = ThreadData::Now(); 102 TrackedTime now = ThreadData::Now();
104 103
105 // Then get a bracketing time. 104 // Then get a bracketing time.
106 base::TimeTicks ticks_after = base::TimeTicks::Now(); 105 base::TimeTicks ticks_after = base::TimeTicks::Now();
107 EXPECT_FALSE(ticks_after.is_null()); 106 EXPECT_FALSE(ticks_after.is_null());
108 107
109 // Now make sure that we bracketed our tracked time nicely. 108 // Now make sure that we bracketed our tracked time nicely.
110 Duration before = now - TrackedTime(ticks_before); 109 Duration before = now - TrackedTime(ticks_before);
111 EXPECT_LE(0, before.InMilliseconds()); 110 EXPECT_LE(0, before.InMilliseconds());
112 Duration after = now - TrackedTime(ticks_after); 111 Duration after = now - TrackedTime(ticks_after);
113 EXPECT_GE(0, after.InMilliseconds()); 112 EXPECT_GE(0, after.InMilliseconds());
114 } 113 }
115 114
116 } // namespace tracked_objects 115 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « no previous file | base/tracked_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698