Index: base/profiler/stack_sampling_profiler_unittest.cc |
diff --git a/base/profiler/stack_sampling_profiler_unittest.cc b/base/profiler/stack_sampling_profiler_unittest.cc |
index 0b300d575d73c76f65a6afd7e53a372020a844a3..d9b13d4b937f50c79f4ca0a703a7a2320c5d43d8 100644 |
--- a/base/profiler/stack_sampling_profiler_unittest.cc |
+++ b/base/profiler/stack_sampling_profiler_unittest.cc |
@@ -351,6 +351,38 @@ void WithTargetThread(Function function) { |
WithTargetThread(function, StackConfiguration(StackConfiguration::NORMAL)); |
} |
+// Waits for one of multiple samplings to complete. |
+void CreateProfilers( |
+ PlatformThreadId target_thread_id, |
+ const std::vector<SamplingParams>& params, |
+ std::vector<CallStackProfiles>* profiles, |
+ std::vector<std::unique_ptr<StackSamplingProfiler>>* profilers, |
+ std::vector<std::unique_ptr<WaitableEvent>>* completed) { |
+ ASSERT_TRUE(!params.empty()); |
+ ASSERT_TRUE(profiles->empty()); |
+ ASSERT_TRUE(profilers->empty()); |
+ ASSERT_TRUE(completed->empty()); |
+ |
+ // Vectors have to be appropriately sized in advance so that the addresses of |
+ // values don't change. |
+ const size_t count = params.size(); |
+ profiles->reserve(count); |
+ profilers->reserve(count); |
+ completed->reserve(count); |
+ |
+ for (size_t i = 0; i < count; ++i) { |
+ profiles->push_back(CallStackProfiles()); |
+ completed->push_back( |
+ MakeUnique<WaitableEvent>(WaitableEvent::ResetPolicy::AUTOMATIC, |
+ WaitableEvent::InitialState::NOT_SIGNALED)); |
+ const StackSamplingProfiler::CompletedCallback callback = |
+ Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles->back()), |
+ Unretained(completed->back().get())); |
+ profilers->push_back(MakeUnique<StackSamplingProfiler>( |
+ target_thread_id, params[i], callback)); |
+ } |
+} |
+ |
// Captures profiles as specified by |params| on the TargetThread, and returns |
// them in |profiles|. Waits up to |profiler_wait_time| for the profiler to |
// complete. |
@@ -374,6 +406,21 @@ void CaptureProfiles(const SamplingParams& params, TimeDelta profiler_wait_time, |
}); |
} |
+// Waits for one of multiple samplings to complete. |
+size_t WaitForSamplingComplete( |
+ std::vector<std::unique_ptr<WaitableEvent>>* sampling_completed) { |
+ // Map unique_ptrs to something that WaitMany can accept. |
+ std::vector<WaitableEvent*> sampling_completed_rawptrs( |
+ sampling_completed->size()); |
+ std::transform( |
+ sampling_completed->begin(), sampling_completed->end(), |
+ sampling_completed_rawptrs.begin(), |
+ [](const std::unique_ptr<WaitableEvent>& elem) { return elem.get(); }); |
+ // Wait for one profiler to finish. |
+ return WaitableEvent::WaitMany(sampling_completed_rawptrs.data(), |
+ sampling_completed_rawptrs.size()); |
+} |
+ |
// If this executable was linked with /INCREMENTAL (the default for non-official |
// debug and release builds on Windows), function addresses do not correspond to |
// function code itself, but instead to instructions in the Incremental Link |
@@ -444,9 +491,9 @@ void TestLibraryUnload(bool wait_until_unloaded) { |
StackCopiedSignaler(WaitableEvent* stack_copied, |
WaitableEvent* start_stack_walk, |
bool wait_to_walk_stack) |
- : stack_copied_(stack_copied), start_stack_walk_(start_stack_walk), |
- wait_to_walk_stack_(wait_to_walk_stack) { |
- } |
+ : stack_copied_(stack_copied), |
+ start_stack_walk_(start_stack_walk), |
+ wait_to_walk_stack_(wait_to_walk_stack) {} |
void OnPreStackWalk() override { |
stack_copied_->Signal(); |
@@ -720,35 +767,6 @@ TEST(StackSamplingProfilerTest, MAYBE_Alloca) { |
<< FormatSampleForDiagnosticOutput(sample, profile.modules); |
} |
-// Checks that the fire-and-forget interface works. |
-#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
-#define MAYBE_StartAndRunAsync StartAndRunAsync |
-#else |
-#define MAYBE_StartAndRunAsync DISABLED_StartAndRunAsync |
-#endif |
-TEST(StackSamplingProfilerTest, MAYBE_StartAndRunAsync) { |
- // StartAndRunAsync requires the caller to have a message loop. |
- MessageLoop message_loop; |
- |
- SamplingParams params; |
- params.samples_per_burst = 1; |
- |
- CallStackProfiles profiles; |
- WithTargetThread([¶ms, &profiles](PlatformThreadId target_thread_id) { |
- WaitableEvent sampling_thread_completed( |
- WaitableEvent::ResetPolicy::AUTOMATIC, |
- WaitableEvent::InitialState::NOT_SIGNALED); |
- const StackSamplingProfiler::CompletedCallback callback = |
- Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles), |
- Unretained(&sampling_thread_completed)); |
- StackSamplingProfiler::StartAndRunAsync(target_thread_id, params, callback); |
- RunLoop().RunUntilIdle(); |
- sampling_thread_completed.Wait(); |
- }); |
- |
- ASSERT_EQ(1u, profiles.size()); |
-} |
- |
// Checks that the expected number of profiles and samples are present in the |
// call stack profiles produced. |
#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
@@ -771,6 +789,31 @@ TEST(StackSamplingProfilerTest, MAYBE_MultipleProfilesAndSamples) { |
EXPECT_EQ(3u, profiles[1].samples.size()); |
} |
+// Checks that a profiler can stop/destruct without ever having started. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_StopWithoutStarting StopWithoutStarting |
+#else |
+#define MAYBE_StopWithoutStarting DISABLED_StopWithoutStarting |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_StopWithoutStarting) { |
+ WithTargetThread([](PlatformThreadId target_thread_id) { |
+ SamplingParams params; |
+ params.sampling_interval = TimeDelta::FromMilliseconds(0); |
+ params.samples_per_burst = 1; |
+ |
+ CallStackProfiles profiles; |
+ WaitableEvent sampling_completed(WaitableEvent::ResetPolicy::MANUAL, |
+ WaitableEvent::InitialState::NOT_SIGNALED); |
+ const StackSamplingProfiler::CompletedCallback callback = |
+ Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles), |
+ Unretained(&sampling_completed)); |
+ StackSamplingProfiler profiler(target_thread_id, params, callback); |
+ |
+ profiler.Stop(); // Constructed but never started. |
+ EXPECT_FALSE(sampling_completed.IsSignaled()); |
+ }); |
+} |
+ |
// Checks that no call stack profiles are captured if the profiling is stopped |
// during the initial delay. |
#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
@@ -860,6 +903,97 @@ TEST(StackSamplingProfilerTest, MAYBE_DestroyProfilerWhileProfiling) { |
#define MAYBE_CanRunMultipleTimes DISABLED_CanRunMultipleTimes |
#endif |
TEST(StackSamplingProfilerTest, MAYBE_CanRunMultipleTimes) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
+ WithTargetThread([](PlatformThreadId target_thread_id) { |
+ SamplingParams params; |
+ params.sampling_interval = TimeDelta::FromMilliseconds(0); |
+ params.samples_per_burst = 1; |
+ |
+ CallStackProfiles profiles; |
+ WaitableEvent sampling_completed(WaitableEvent::ResetPolicy::MANUAL, |
+ WaitableEvent::InitialState::NOT_SIGNALED); |
+ const StackSamplingProfiler::CompletedCallback callback = |
+ Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles), |
+ Unretained(&sampling_completed)); |
+ StackSamplingProfiler profiler(target_thread_id, params, callback); |
+ |
+ // Just start and stop to execute code paths. |
+ profiler.Start(); |
+ profiler.Stop(); |
+ sampling_completed.Wait(); |
+ |
+ // Ensure a second request will run and not block. |
+ sampling_completed.Reset(); |
+ profiles.clear(); |
+ profiler.Start(); |
+ sampling_completed.Wait(); |
+ profiler.Stop(); |
+ ASSERT_EQ(1u, profiles.size()); |
+ }); |
+} |
+ |
+// Checks that the different profilers may be run. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_CanRunMultipleProfilers CanRunMultipleProfilers |
+#else |
+#define MAYBE_CanRunMultipleProfilers DISABLED_CanRunMultipleProfilers |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_CanRunMultipleProfilers) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
+ SamplingParams params; |
+ params.sampling_interval = TimeDelta::FromMilliseconds(0); |
+ params.samples_per_burst = 1; |
+ |
+ std::vector<CallStackProfile> profiles; |
+ CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); |
+ ASSERT_EQ(1u, profiles.size()); |
+ |
+ profiles.clear(); |
+ CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); |
+ ASSERT_EQ(1u, profiles.size()); |
+} |
+ |
+// Checks that the sampling thread can shut down. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_SamplerIdleShutdown SamplerIdleShutdown |
+#else |
+#define MAYBE_SamplerIdleShutdown DISABLED_SamplerIdleShutdown |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_SamplerIdleShutdown) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
+ SamplingParams params; |
+ params.sampling_interval = TimeDelta::FromMilliseconds(0); |
+ params.samples_per_burst = 1; |
+ |
+ std::vector<CallStackProfile> profiles; |
+ CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); |
+ ASSERT_EQ(1u, profiles.size()); |
+ |
+ // Capture thread should still be running at this point. |
+ ASSERT_TRUE(StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()); |
+ |
+ // Initiate an "idle" shutdown and ensure it happens. Idle-shutdown was |
+ // disabled above so the test will fail due to a timeout if it does not |
+ // exit. |
+ StackSamplingProfiler::TestAPI::InitiateSamplingThreadIdleShutdown(); |
+ while (StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()) |
+ PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
+} |
+ |
+// Checks that additional requests will restart a stopped profiler. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_WillRestartSamplerAfterIdleShutdown \ |
+ WillRestartSamplerAfterIdleShutdown |
+#else |
+#define MAYBE_WillRestartSamplerAfterIdleShutdown \ |
+ DISABLED_WillRestartSamplerAfterIdleShutdown |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_WillRestartSamplerAfterIdleShutdown) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
SamplingParams params; |
params.sampling_interval = TimeDelta::FromMilliseconds(0); |
params.samples_per_burst = 1; |
@@ -868,65 +1002,197 @@ TEST(StackSamplingProfilerTest, MAYBE_CanRunMultipleTimes) { |
CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); |
ASSERT_EQ(1u, profiles.size()); |
+ // Capture thread should still be running at this point. |
+ ASSERT_TRUE(StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()); |
+ |
+ // Initiate an "idle" shutdown. Waiting for it to actually exit is the only |
+ // way of knowing below that the thread "restarted". |
+ StackSamplingProfiler::TestAPI::InitiateSamplingThreadIdleShutdown(); |
+ while (StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()) |
Mike Wittman
2017/03/23 22:18:31
Since the previous test has already established th
bcwhite
2017/03/27 17:52:43
It's not enough to know that it will exit. It mus
Mike Wittman
2017/03/28 19:32:02
That's true. The explicit event for shutdown run r
|
+ PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
+ |
+ // Ensure another capture will start the sampling thread and run. |
profiles.clear(); |
CaptureProfiles(params, AVeryLongTimeDelta(), &profiles); |
ASSERT_EQ(1u, profiles.size()); |
+ EXPECT_TRUE(StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()); |
+} |
+ |
+// Checks that it's safe to stop a task after it's completed and the sampling |
+// thread has shut-down for being idle. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_StopAfterIdleShutdown StopAfterIdleShutdown |
+#else |
+#define MAYBE_StopAfterIdleShutdown DISABLED_StopAfterIdleShutdown |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_StopAfterIdleShutdown) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
+ WithTargetThread([](PlatformThreadId target_thread_id) { |
+ SamplingParams params; |
+ params.sampling_interval = TimeDelta::FromMilliseconds(0); |
+ params.samples_per_burst = 1; |
+ |
+ CallStackProfiles profiles; |
+ WaitableEvent sampling_completed(WaitableEvent::ResetPolicy::MANUAL, |
+ WaitableEvent::InitialState::NOT_SIGNALED); |
+ const StackSamplingProfiler::CompletedCallback callback = |
+ Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles), |
+ Unretained(&sampling_completed)); |
+ StackSamplingProfiler profiler(target_thread_id, params, callback); |
+ |
+ // Let it run and then stop due to being idle. The thread will go into the |
+ // EXITING state (and remain there) sometime after the Initiate call posts |
+ // its task and before the thread actually exits. |
Mike Wittman
2017/03/23 22:18:31
This is much better, although I think this informa
bcwhite
2017/03/27 17:52:43
Acknowledged.
|
+ profiler.Start(); |
+ sampling_completed.Wait(); |
+ StackSamplingProfiler::TestAPI::InitiateSamplingThreadIdleShutdown(); |
Mike Wittman
2017/03/23 22:18:31
// Post a ShutdownTask on the sampling thread, whi
bcwhite
2017/03/27 17:52:43
Done.
|
+ while (StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()) |
Mike Wittman
2017/03/23 22:18:31
// Wait for the thread to exit to ensure the Shutd
bcwhite
2017/03/27 17:52:43
Done.
|
+ PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
+ |
+ // Ensure it's still safe to stop. |
Mike Wittman
2017/03/23 22:18:31
// Attempt to stop the profiler now that we know t
bcwhite
2017/03/27 17:52:43
Done.
|
+ profiler.Stop(); |
+ EXPECT_FALSE(StackSamplingProfiler::TestAPI::IsSamplingThreadRunning()); |
+ }); |
} |
-// Checks that requests to start profiling while another profile is taking place |
-// are ignored. |
+// Checks that synchronized multiple sampling requests execute in parallel. |
#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
-#define MAYBE_ConcurrentProfiling ConcurrentProfiling |
+#define MAYBE_ConcurrentProfiling_InSync ConcurrentProfiling_InSync |
#else |
-#define MAYBE_ConcurrentProfiling DISABLED_ConcurrentProfiling |
+#define MAYBE_ConcurrentProfiling_InSync DISABLED_ConcurrentProfiling_InSync |
#endif |
-TEST(StackSamplingProfilerTest, MAYBE_ConcurrentProfiling) { |
+TEST(StackSamplingProfilerTest, MAYBE_ConcurrentProfiling_InSync) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
WithTargetThread([](PlatformThreadId target_thread_id) { |
- SamplingParams params[2]; |
+ std::vector<SamplingParams> params(2); |
+ |
+ // Providing an initial delay makes it more likely that both will be |
+ // scheduled before either starts to run. Once started, samples will |
+ // run ordered by their scheduled, interleaved times regardless of |
+ // whatever interval the thread wakes up. Thus, total execution time |
+ // will be 10ms (delay) + 10x1ms (sampling) + 1/2 timer minimum interval. |
params[0].initial_delay = TimeDelta::FromMilliseconds(10); |
- params[0].sampling_interval = TimeDelta::FromMilliseconds(0); |
- params[0].samples_per_burst = 1; |
+ params[0].sampling_interval = TimeDelta::FromMilliseconds(1); |
+ params[0].samples_per_burst = 9; |
- params[1].sampling_interval = TimeDelta::FromMilliseconds(0); |
- params[1].samples_per_burst = 1; |
- |
- CallStackProfiles profiles[2]; |
- std::vector<std::unique_ptr<WaitableEvent>> sampling_completed(2); |
- std::vector<std::unique_ptr<StackSamplingProfiler>> profiler(2); |
- for (int i = 0; i < 2; ++i) { |
- sampling_completed[i] = |
- MakeUnique<WaitableEvent>(WaitableEvent::ResetPolicy::AUTOMATIC, |
- WaitableEvent::InitialState::NOT_SIGNALED); |
- const StackSamplingProfiler::CompletedCallback callback = |
- Bind(&SaveProfilesAndSignalEvent, Unretained(&profiles[i]), |
- Unretained(sampling_completed[i].get())); |
- profiler[i] = MakeUnique<StackSamplingProfiler>(target_thread_id, |
- params[i], callback); |
- } |
+ params[1].initial_delay = TimeDelta::FromMilliseconds(11); |
+ params[1].sampling_interval = TimeDelta::FromMilliseconds(1); |
+ params[1].samples_per_burst = 8; |
+ |
+ std::vector<CallStackProfiles> profiles; |
+ std::vector<std::unique_ptr<StackSamplingProfiler>> profilers; |
+ std::vector<std::unique_ptr<WaitableEvent>> sampling_completed; |
+ CreateProfilers(target_thread_id, params, &profiles, &profilers, |
+ &sampling_completed); |
- profiler[0]->Start(); |
- profiler[1]->Start(); |
+ profilers[0]->Start(); |
+ profilers[1]->Start(); |
- std::vector<WaitableEvent*> sampling_completed_rawptrs( |
- sampling_completed.size()); |
- std::transform( |
- sampling_completed.begin(), sampling_completed.end(), |
- sampling_completed_rawptrs.begin(), |
- [](const std::unique_ptr<WaitableEvent>& elem) { return elem.get(); }); |
// Wait for one profiler to finish. |
- size_t completed_profiler = |
- WaitableEvent::WaitMany(sampling_completed_rawptrs.data(), 2); |
- EXPECT_EQ(1u, profiles[completed_profiler].size()); |
+ size_t completed_profiler = WaitForSamplingComplete(&sampling_completed); |
+ ASSERT_EQ(1u, profiles[completed_profiler].size()); |
size_t other_profiler = 1 - completed_profiler; |
- // Give the other profiler a chance to run and observe that it hasn't. |
- EXPECT_FALSE(sampling_completed[other_profiler]->TimedWait( |
- TimeDelta::FromMilliseconds(25))); |
- |
- // Start the other profiler again and it should run. |
- profiler[other_profiler]->Start(); |
+ // Wait for the other profiler to finish. |
sampling_completed[other_profiler]->Wait(); |
- EXPECT_EQ(1u, profiles[other_profiler].size()); |
+ ASSERT_EQ(1u, profiles[other_profiler].size()); |
+ |
+ // Ensure each got the correct number of samples. |
+ EXPECT_EQ(9u, profiles[0][0].samples.size()); |
+ EXPECT_EQ(8u, profiles[1][0].samples.size()); |
+ }); |
+} |
+ |
+// Checks that several mixed sampling requests execute in parallel. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_ConcurrentProfiling_Mixed ConcurrentProfiling_Mixed |
+#else |
+#define MAYBE_ConcurrentProfiling_Mixed DISABLED_ConcurrentProfiling_Mixed |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_ConcurrentProfiling_Mixed) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
+ WithTargetThread([](PlatformThreadId target_thread_id) { |
+ std::vector<SamplingParams> params(3); |
+ |
+ params[0].initial_delay = TimeDelta::FromMilliseconds(8); |
+ params[0].sampling_interval = TimeDelta::FromMilliseconds(4); |
+ params[0].samples_per_burst = 10; |
+ |
+ params[1].initial_delay = TimeDelta::FromMilliseconds(9); |
+ params[1].sampling_interval = TimeDelta::FromMilliseconds(3); |
+ params[1].samples_per_burst = 10; |
+ |
+ params[2].initial_delay = TimeDelta::FromMilliseconds(10); |
+ params[2].sampling_interval = TimeDelta::FromMilliseconds(2); |
+ params[2].samples_per_burst = 10; |
+ |
+ std::vector<CallStackProfiles> profiles; |
+ std::vector<std::unique_ptr<StackSamplingProfiler>> profilers; |
+ std::vector<std::unique_ptr<WaitableEvent>> sampling_completed; |
+ CreateProfilers(target_thread_id, params, &profiles, &profilers, |
+ &sampling_completed); |
+ |
+ for (size_t i = 0; i < profilers.size(); ++i) |
+ profilers[i]->Start(); |
+ |
+ // Wait for one profiler to finish. |
+ size_t completed_profiler = WaitForSamplingComplete(&sampling_completed); |
+ EXPECT_EQ(1u, profiles[completed_profiler].size()); |
+ // Stop and destroy all profilers, always in the same order. Don't crash. |
+ for (size_t i = 0; i < profilers.size(); ++i) |
+ profilers[i]->Stop(); |
+ for (size_t i = 0; i < profilers.size(); ++i) |
+ profilers[i].reset(); |
+ }); |
+} |
+ |
+// Checks that sampling requests execute in a staggered manner. |
+#if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
+#define MAYBE_ConcurrentProfiling_Staggered ConcurrentProfiling_Staggered |
+#else |
+#define MAYBE_ConcurrentProfiling_Staggered \ |
+ DISABLED_ConcurrentProfiling_Staggered |
+#endif |
+TEST(StackSamplingProfilerTest, MAYBE_ConcurrentProfiling_Staggered) { |
+ StackSamplingProfiler::TestAPI::DisableIdleShutdown(); |
+ |
+ WithTargetThread([](PlatformThreadId target_thread_id) { |
+ std::vector<SamplingParams> params(3); |
+ |
+ // Create an arbitrary variety of sampling parameters. The exact values of |
+ // these are unimportant other than they should not run too long. |
+ params[0].initial_delay = TimeDelta::FromMilliseconds(10); |
+ params[0].sampling_interval = TimeDelta::FromMilliseconds(10); |
+ params[0].samples_per_burst = 1; |
+ |
+ params[1].initial_delay = TimeDelta::FromMilliseconds(5); |
+ params[1].sampling_interval = TimeDelta::FromMilliseconds(10); |
+ params[1].samples_per_burst = 2; |
+ |
+ params[2].initial_delay = TimeDelta::FromMilliseconds(0); |
+ params[2].sampling_interval = TimeDelta::FromMilliseconds(10); |
+ params[2].samples_per_burst = 3; |
+ |
+ std::vector<CallStackProfiles> profiles; |
+ std::vector<std::unique_ptr<StackSamplingProfiler>> profilers; |
+ std::vector<std::unique_ptr<WaitableEvent>> sampling_completed; |
+ CreateProfilers(target_thread_id, params, &profiles, &profilers, |
+ &sampling_completed); |
+ |
+ profilers[0]->Start(); |
+ profilers[1]->Start(); |
+ sampling_completed[0]->Wait(); |
+ profilers[0]->Stop(); |
+ profilers[2]->Start(); |
+ profilers[1]->Stop(); |
+ sampling_completed[1]->Wait(); |
+ sampling_completed[2]->Wait(); |
+ EXPECT_EQ(1u, profiles[0].size()); |
+ EXPECT_EQ(1u, profiles[1].size()); |
+ EXPECT_EQ(1u, profiles[2].size()); |
}); |
} |