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

Side by Side Diff: base/profiler/stack_sampling_profiler.h

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, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ 5 #ifndef BASE_PROFILER_STACK_SAMPLING_PROFILER_H_
6 #define BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ 6 #define BASE_PROFILER_STACK_SAMPLING_PROFILER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // profiler.Start(); 44 // profiler.Start();
45 // // ... work being done on the target thread here ... 45 // // ... work being done on the target thread here ...
46 // profiler.Stop(); // optional, stops collection before complete per params 46 // profiler.Stop(); // optional, stops collection before complete per params
47 // 47 //
48 // The default SamplingParams causes stacks to be recorded in a single burst at 48 // The default SamplingParams causes stacks to be recorded in a single burst at
49 // a 10Hz interval for a total of 30 seconds. All of these parameters may be 49 // a 10Hz interval for a total of 30 seconds. All of these parameters may be
50 // altered as desired. 50 // altered as desired.
51 // 51 //
52 // When all call stack profiles are complete, or the profiler is stopped, the 52 // When all call stack profiles are complete, or the profiler is stopped, the
53 // completed callback is called from a thread created by the profiler with the 53 // completed callback is called from a thread created by the profiler with the
54 // completed profiles. A profile is considered complete if all requested samples 54 // collected profiles.
55 // were recorded for the profile (i.e. it was not stopped prematurely).
56 // 55 //
57 // The results of the profiling are passed to the completed callback and consist 56 // The results of the profiling are passed to the completed callback and consist
58 // of a vector of CallStackProfiles. Each CallStackProfile corresponds to a 57 // of a vector of CallStackProfiles. Each CallStackProfile corresponds to a
59 // burst as specified in SamplingParams and contains a set of Samples and 58 // burst as specified in SamplingParams and contains a set of Samples and
60 // Modules. One Sample corresponds to a single recorded stack, and the Modules 59 // Modules. One Sample corresponds to a single recorded stack, and the Modules
61 // record those modules associated with the recorded stack frames. 60 // record those modules associated with the recorded stack frames.
62 class BASE_EXPORT StackSamplingProfiler { 61 class BASE_EXPORT StackSamplingProfiler {
63 public: 62 public:
64 // Module represents the module (DLL or exe) corresponding to a stack frame. 63 // Module represents the module (DLL or exe) corresponding to a stack frame.
65 struct BASE_EXPORT Module { 64 struct BASE_EXPORT Module {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 const SamplingParams& params, 187 const SamplingParams& params,
189 const CompletedCallback& completed_callback); 188 const CompletedCallback& completed_callback);
190 ~SamplingThread() override; 189 ~SamplingThread() override;
191 190
192 // PlatformThread::Delegate: 191 // PlatformThread::Delegate:
193 void ThreadMain() override; 192 void ThreadMain() override;
194 193
195 void Stop(); 194 void Stop();
196 195
197 private: 196 private:
198 // Collects a call stack profile from a single burst. Returns true if the 197 // Collects |profile| from a single burst. If the profiler was stopped
199 // profile was collected, or false if collection was stopped before it 198 // during collection, sets |was_stopped| and provides the set of samples
200 // completed. 199 // collected up to that point.
201 bool CollectProfile(CallStackProfile* profile, TimeDelta* elapsed_time); 200 void CollectProfile(CallStackProfile* profile, TimeDelta* elapsed_time,
201 bool* was_stopped);
202 202
203 // Collects call stack profiles from all bursts, or until the sampling is 203 // Collects call stack profiles from all bursts, or until the sampling is
204 // stopped. If stopped before complete, |call_stack_profiles| will contain 204 // stopped. If stopped before complete, the last profile in
205 // only full bursts. 205 // |call_stack_profiles| may contain a partial burst.
206 void CollectProfiles(CallStackProfiles* profiles); 206 void CollectProfiles(CallStackProfiles* profiles);
207 207
208 scoped_ptr<NativeStackSampler> native_sampler_; 208 scoped_ptr<NativeStackSampler> native_sampler_;
209 const SamplingParams params_; 209 const SamplingParams params_;
210 210
211 // If Stop() is called, it signals this event to force the sampling to 211 // If Stop() is called, it signals this event to force the sampling to
212 // terminate before all the samples specified in |params_| are collected. 212 // terminate before all the samples specified in |params_| are collected.
213 WaitableEvent stop_event_; 213 WaitableEvent stop_event_;
214 214
215 const CompletedCallback completed_callback_; 215 const CompletedCallback completed_callback_;
(...skipping 17 matching lines...) Expand all
233 // The metrics provider code wants to put Samples in a map and compare them, 233 // The metrics provider code wants to put Samples in a map and compare them,
234 // which requires us to define a few operators. 234 // which requires us to define a few operators.
235 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a, 235 BASE_EXPORT bool operator==(const StackSamplingProfiler::Frame& a,
236 const StackSamplingProfiler::Frame& b); 236 const StackSamplingProfiler::Frame& b);
237 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a, 237 BASE_EXPORT bool operator<(const StackSamplingProfiler::Frame& a,
238 const StackSamplingProfiler::Frame& b); 238 const StackSamplingProfiler::Frame& b);
239 239
240 } // namespace base 240 } // namespace base
241 241
242 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_ 242 #endif // BASE_PROFILER_STACK_SAMPLING_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698