Commit c724ade5 authored by Xi Cheng's avatar Xi Cheng Committed by Commit Bot

Introduce const struct kSamplingParams to replace GetSamplingParams()

Bug: 851163
Change-Id: Ia6d200535697101d6c76edbfe2b117a3f5d3d733
Reviewed-on: https://chromium-review.googlesource.com/1113201
Commit-Queue: Xi Cheng <chengx@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570150}
parent a65105c1
...@@ -38,13 +38,10 @@ base::LazyInstance< ...@@ -38,13 +38,10 @@ base::LazyInstance<
// Run continuous profiling 2% of the time. // Run continuous profiling 2% of the time.
constexpr const double kFractionOfExecutionTimeToSample = 0.02; constexpr const double kFractionOfExecutionTimeToSample = 0.02;
base::StackSamplingProfiler::SamplingParams GetSamplingParams() { constexpr struct base::StackSamplingProfiler::SamplingParams kSamplingParams = {
base::StackSamplingProfiler::SamplingParams params; /* initial_delay= */ base::TimeDelta::FromMilliseconds(0),
params.initial_delay = base::TimeDelta::FromMilliseconds(0); /* samples_per_profile= */ 300,
params.samples_per_profile = 300; /* sampling_interval= */ base::TimeDelta::FromMilliseconds(100)};
params.sampling_interval = base::TimeDelta::FromMilliseconds(100);
return params;
}
metrics::CallStackProfileParams::Process GetProcess() { metrics::CallStackProfileParams::Process GetProcess() {
const base::CommandLine* command_line = const base::CommandLine* command_line =
...@@ -194,7 +191,7 @@ ThreadProfiler::ThreadProfiler( ...@@ -194,7 +191,7 @@ ThreadProfiler::ThreadProfiler(
return; return;
startup_profiler_ = std::make_unique<base::StackSamplingProfiler>( startup_profiler_ = std::make_unique<base::StackSamplingProfiler>(
base::PlatformThread::CurrentId(), GetSamplingParams(), base::PlatformThread::CurrentId(), kSamplingParams,
BindRepeating(&ThreadProfiler::ReceiveStartupProfile, BindRepeating(&ThreadProfiler::ReceiveStartupProfile,
GetReceiverCallback(metrics::CallStackProfileParams( GetReceiverCallback(metrics::CallStackProfileParams(
GetProcess(), thread, GetProcess(), thread,
...@@ -202,19 +199,16 @@ ThreadProfiler::ThreadProfiler( ...@@ -202,19 +199,16 @@ ThreadProfiler::ThreadProfiler(
metrics::CallStackProfileParams::MAY_SHUFFLE)))); metrics::CallStackProfileParams::MAY_SHUFFLE))));
startup_profiler_->Start(); startup_profiler_->Start();
const base::StackSamplingProfiler::SamplingParams& sampling_params =
GetSamplingParams();
// Estimated time at which the startup profiling will be completed. It's OK if // Estimated time at which the startup profiling will be completed. It's OK if
// this doesn't exactly coincide with the end of the startup profiling, since // this doesn't exactly coincide with the end of the startup profiling, since
// there's no harm in having a brief overlap of startup and periodic // there's no harm in having a brief overlap of startup and periodic
// profiling. // profiling.
base::TimeTicks startup_profiling_completion_time = base::TimeTicks startup_profiling_completion_time =
base::TimeTicks::Now() + base::TimeTicks::Now() +
sampling_params.samples_per_profile * sampling_params.sampling_interval; kSamplingParams.samples_per_profile * kSamplingParams.sampling_interval;
periodic_sampling_scheduler_ = std::make_unique<PeriodicSamplingScheduler>( periodic_sampling_scheduler_ = std::make_unique<PeriodicSamplingScheduler>(
sampling_params.samples_per_profile * sampling_params.sampling_interval, kSamplingParams.samples_per_profile * kSamplingParams.sampling_interval,
kFractionOfExecutionTimeToSample, startup_profiling_completion_time); kFractionOfExecutionTimeToSample, startup_profiling_completion_time);
if (owning_thread_task_runner_) if (owning_thread_task_runner_)
...@@ -278,7 +272,7 @@ void ThreadProfiler::StartPeriodicSamplingCollection() { ...@@ -278,7 +272,7 @@ void ThreadProfiler::StartPeriodicSamplingCollection() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// NB: Destroys the previous profiler as side effect. // NB: Destroys the previous profiler as side effect.
periodic_profiler_ = std::make_unique<base::StackSamplingProfiler>( periodic_profiler_ = std::make_unique<base::StackSamplingProfiler>(
base::PlatformThread::CurrentId(), GetSamplingParams(), base::PlatformThread::CurrentId(), kSamplingParams,
BindRepeating(&ThreadProfiler::ReceivePeriodicProfile, BindRepeating(&ThreadProfiler::ReceivePeriodicProfile,
GetReceiverCallback(periodic_profile_params_), GetReceiverCallback(periodic_profile_params_),
owning_thread_task_runner_, weak_factory_.GetWeakPtr())); owning_thread_task_runner_, weak_factory_.GetWeakPtr()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment