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