| Index: profiler/stack_sampling_profiler.cc
|
| diff --git a/profiler/stack_sampling_profiler.cc b/profiler/stack_sampling_profiler.cc
|
| index 7f12b71e623a56e6359db931cf700d3a5014f9a4..b74f74532c00c9b50da0e3e0b4b0b2d6729b797f 100644
|
| --- a/profiler/stack_sampling_profiler.cc
|
| +++ b/profiler/stack_sampling_profiler.cc
|
| @@ -139,14 +139,14 @@ void StackSamplingProfiler::SamplingThread::ThreadMain() {
|
| // adhering to the sampling intervals. Once we have established users for the
|
| // StackSamplingProfiler and the collected data to judge, we may go the other
|
| // way or make this behavior configurable.
|
| -bool StackSamplingProfiler::SamplingThread::CollectProfile(
|
| +void StackSamplingProfiler::SamplingThread::CollectProfile(
|
| CallStackProfile* profile,
|
| - TimeDelta* elapsed_time) {
|
| + TimeDelta* elapsed_time,
|
| + bool* was_stopped) {
|
| ElapsedTimer profile_timer;
|
| - CallStackProfile current_profile;
|
| - native_sampler_->ProfileRecordingStarting(¤t_profile.modules);
|
| - current_profile.sampling_period = params_.sampling_interval;
|
| - bool burst_completed = true;
|
| + native_sampler_->ProfileRecordingStarting(&profile->modules);
|
| + profile->sampling_period = params_.sampling_interval;
|
| + *was_stopped = false;
|
| TimeDelta previous_elapsed_sample_time;
|
| for (int i = 0; i < params_.samples_per_burst; ++i) {
|
| if (i != 0) {
|
| @@ -155,24 +155,19 @@ bool StackSamplingProfiler::SamplingThread::CollectProfile(
|
| if (stop_event_.TimedWait(
|
| std::max(params_.sampling_interval - previous_elapsed_sample_time,
|
| TimeDelta()))) {
|
| - burst_completed = false;
|
| + *was_stopped = true;
|
| break;
|
| }
|
| }
|
| ElapsedTimer sample_timer;
|
| - current_profile.samples.push_back(Sample());
|
| - native_sampler_->RecordStackSample(¤t_profile.samples.back());
|
| + profile->samples.push_back(Sample());
|
| + native_sampler_->RecordStackSample(&profile->samples.back());
|
| previous_elapsed_sample_time = sample_timer.Elapsed();
|
| }
|
|
|
| *elapsed_time = profile_timer.Elapsed();
|
| - current_profile.profile_duration = *elapsed_time;
|
| + profile->profile_duration = *elapsed_time;
|
| native_sampler_->ProfileRecordingStopped();
|
| -
|
| - if (burst_completed)
|
| - *profile = current_profile;
|
| -
|
| - return burst_completed;
|
| }
|
|
|
| // In an analogous manner to CollectProfile() and samples exceeding the expected
|
| @@ -195,9 +190,13 @@ void StackSamplingProfiler::SamplingThread::CollectProfiles(
|
| }
|
|
|
| CallStackProfile profile;
|
| - if (!CollectProfile(&profile, &previous_elapsed_profile_time))
|
| + bool was_stopped = false;
|
| + CollectProfile(&profile, &previous_elapsed_profile_time, &was_stopped);
|
| + if (!profile.samples.empty())
|
| + profiles->push_back(profile);
|
| +
|
| + if (was_stopped)
|
| return;
|
| - profiles->push_back(profile);
|
| }
|
| }
|
|
|
|
|