OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/profiler/stack_sampling_profiler.h" | 10 #include "base/profiler/stack_sampling_profiler.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 params.bursts = 2; | 339 params.bursts = 2; |
340 params.samples_per_burst = 1; | 340 params.samples_per_burst = 1; |
341 | 341 |
342 std::vector<CallStackProfile> profiles; | 342 std::vector<CallStackProfile> profiles; |
343 CaptureProfiles(params, TimeDelta::FromMilliseconds(50), &profiles); | 343 CaptureProfiles(params, TimeDelta::FromMilliseconds(50), &profiles); |
344 | 344 |
345 ASSERT_EQ(1u, profiles.size()); | 345 ASSERT_EQ(1u, profiles.size()); |
346 EXPECT_EQ(1u, profiles[0].samples.size()); | 346 EXPECT_EQ(1u, profiles[0].samples.size()); |
347 } | 347 } |
348 | 348 |
349 // Checks that only completed call stack profiles are captured. | 349 // Checks that incomplete call stack profiles are captured. |
350 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 350 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
351 #define MAYBE_StopDuringInterSampleInterval StopDuringInterSampleInterval | 351 #define MAYBE_StopDuringInterSampleInterval StopDuringInterSampleInterval |
352 #else | 352 #else |
353 #define MAYBE_StopDuringInterSampleInterval \ | 353 #define MAYBE_StopDuringInterSampleInterval \ |
354 DISABLED_StopDuringInterSampleInterval | 354 DISABLED_StopDuringInterSampleInterval |
355 #endif | 355 #endif |
356 TEST(StackSamplingProfilerTest, MAYBE_StopDuringInterSampleInterval) { | 356 TEST(StackSamplingProfilerTest, MAYBE_StopDuringInterSampleInterval) { |
357 SamplingParams params; | 357 SamplingParams params; |
358 params.sampling_interval = TimeDelta::FromSeconds(60); | 358 params.sampling_interval = TimeDelta::FromSeconds(60); |
359 params.samples_per_burst = 2; | 359 params.samples_per_burst = 2; |
360 | 360 |
361 std::vector<CallStackProfile> profiles; | 361 std::vector<CallStackProfile> profiles; |
362 CaptureProfiles(params, TimeDelta::FromMilliseconds(50), &profiles); | 362 CaptureProfiles(params, TimeDelta::FromMilliseconds(50), &profiles); |
363 | 363 |
364 EXPECT_TRUE(profiles.empty()); | 364 ASSERT_EQ(1u, profiles.size()); |
| 365 EXPECT_EQ(1u, profiles[0].samples.size()); |
365 } | 366 } |
366 | 367 |
367 // Checks that we can destroy the profiler while profiling. | 368 // Checks that we can destroy the profiler while profiling. |
368 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 369 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
369 #define MAYBE_DestroyProfilerWhileProfiling DestroyProfilerWhileProfiling | 370 #define MAYBE_DestroyProfilerWhileProfiling DestroyProfilerWhileProfiling |
370 #else | 371 #else |
371 #define MAYBE_DestroyProfilerWhileProfiling \ | 372 #define MAYBE_DestroyProfilerWhileProfiling \ |
372 DISABLED_DestroyProfilerWhileProfiling | 373 DISABLED_DestroyProfilerWhileProfiling |
373 #endif | 374 #endif |
374 TEST(StackSamplingProfilerTest, MAYBE_DestroyProfilerWhileProfiling) { | 375 TEST(StackSamplingProfilerTest, MAYBE_DestroyProfilerWhileProfiling) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 sampling_completed[1]->TimedWait(TimeDelta::FromMilliseconds(25))); | 451 sampling_completed[1]->TimedWait(TimeDelta::FromMilliseconds(25))); |
451 | 452 |
452 // Start the second profiler again and it should run. | 453 // Start the second profiler again and it should run. |
453 profiler[1]->Start(); | 454 profiler[1]->Start(); |
454 sampling_completed[1]->Wait(); | 455 sampling_completed[1]->Wait(); |
455 EXPECT_EQ(1u, profiles[1].size()); | 456 EXPECT_EQ(1u, profiles[1].size()); |
456 }); | 457 }); |
457 } | 458 } |
458 | 459 |
459 } // namespace base | 460 } // namespace base |
OLD | NEW |