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/logging.h" | 5 #include "base/logging.h" |
6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
7 #include "base/win/sampling_profiler.h" | 7 #include "base/win/sampling_profiler.h" |
8 #include "base/win/pe_image.h" | 8 #include "base/win/pe_image.h" |
9 #include "base/win/scoped_handle.h" | 9 #include "base/win/scoped_handle.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 profiler.Initialize(process.Get(), code_start, code_size, 31)); | 71 profiler.Initialize(process.Get(), code_start, code_size, 31)); |
72 | 72 |
73 ASSERT_EQ(1, profiler.buckets().size()); | 73 ASSERT_EQ(1, profiler.buckets().size()); |
74 ASSERT_EQ(0, profiler.buckets()[0]); | 74 ASSERT_EQ(0, profiler.buckets()[0]); |
75 | 75 |
76 // We use a roomy timeout to make sure this test is not flaky. | 76 // We use a roomy timeout to make sure this test is not flaky. |
77 // On the buildbots, there may not be a whole lot of CPU time | 77 // On the buildbots, there may not be a whole lot of CPU time |
78 // allotted to our process in this wall-clock time duration, | 78 // allotted to our process in this wall-clock time duration, |
79 // and samples will only accrue while this thread is busy on | 79 // and samples will only accrue while this thread is busy on |
80 // a CPU core. | 80 // a CPU core. |
81 base::TimeDelta spin_time = | 81 base::TimeDelta spin_time = TestTimeouts::action_timeout(); |
82 base::TimeDelta::FromMilliseconds(TestTimeouts::action_timeout_ms()); | |
83 | 82 |
84 base::TimeDelta save_sampling_interval; | 83 base::TimeDelta save_sampling_interval; |
85 ASSERT_TRUE(SamplingProfiler::GetSamplingInterval(&save_sampling_interval)); | 84 ASSERT_TRUE(SamplingProfiler::GetSamplingInterval(&save_sampling_interval)); |
86 | 85 |
87 // Sample every 0.5 millisecs. | 86 // Sample every 0.5 millisecs. |
88 ASSERT_TRUE(SamplingProfiler::SetSamplingInterval( | 87 ASSERT_TRUE(SamplingProfiler::SetSamplingInterval( |
89 base::TimeDelta::FromMicroseconds(500))); | 88 base::TimeDelta::FromMicroseconds(500))); |
90 | 89 |
91 ASSERT_TRUE(SamplingProfiler::SetSamplingInterval( | 90 ASSERT_TRUE(SamplingProfiler::SetSamplingInterval( |
92 base::TimeDelta::FromMicroseconds(500))); | 91 base::TimeDelta::FromMicroseconds(500))); |
(...skipping 19 matching lines...) Expand all Loading... |
112 | 111 |
113 // Restore the sampling interval we found. | 112 // Restore the sampling interval we found. |
114 ASSERT_TRUE(SamplingProfiler::SetSamplingInterval(save_sampling_interval)); | 113 ASSERT_TRUE(SamplingProfiler::SetSamplingInterval(save_sampling_interval)); |
115 | 114 |
116 // Check that we got some samples. | 115 // Check that we got some samples. |
117 ASSERT_NE(0U, profiler.buckets()[0]); | 116 ASSERT_NE(0U, profiler.buckets()[0]); |
118 } | 117 } |
119 | 118 |
120 } // namespace win | 119 } // namespace win |
121 } // namespace base | 120 } // namespace base |
OLD | NEW |