Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Unified Diff: base/profiler/stack_sampling_profiler.cc

Issue 1316153002: StackSamplingProfiler: collect partial bursts if the profiler is stopped early (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/profiler/stack_sampling_profiler.h ('k') | base/profiler/stack_sampling_profiler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/stack_sampling_profiler.cc
diff --git a/base/profiler/stack_sampling_profiler.cc b/base/profiler/stack_sampling_profiler.cc
index 00a79b55bd7fd465f423fa3202bb48661d26e96a..f2467c332d86a81df38239a89d7491615129e8c2 100644
--- a/base/profiler/stack_sampling_profiler.cc
+++ b/base/profiler/stack_sampling_profiler.cc
@@ -141,14 +141,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(&current_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) {
@@ -157,24 +157,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(&current_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
@@ -197,9 +192,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);
}
}
« no previous file with comments | « base/profiler/stack_sampling_profiler.h ('k') | base/profiler/stack_sampling_profiler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698