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

Unified Diff: src/cpu-profiler.cc

Issue 23583036: Check if timeout has expired after processing each sample (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated comment Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cpu-profiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cpu-profiler.cc
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc
index 35fe7888646c0e37adcc5944947d3f15feaeabf4..0d0abe9a43e02bafd58ed4858aba6a9f6d18e28c 100644
--- a/src/cpu-profiler.cc
+++ b/src/cpu-profiler.cc
@@ -104,49 +104,45 @@ bool ProfilerEventsProcessor::ProcessCodeEvent() {
}
-bool ProfilerEventsProcessor::ProcessTicks() {
- while (true) {
- while (!ticks_from_vm_buffer_.IsEmpty()
- && ticks_from_vm_buffer_.Peek()->order ==
- last_processed_code_event_id_) {
- TickSampleEventRecord record;
- ticks_from_vm_buffer_.Dequeue(&record);
- generator_->RecordTickSample(record.sample);
- }
-
- const TickSampleEventRecord* record = ticks_buffer_.StartDequeue();
- if (record == NULL) return !ticks_from_vm_buffer_.IsEmpty();
- if (record->order != last_processed_code_event_id_) return true;
- generator_->RecordTickSample(record->sample);
- ticks_buffer_.FinishDequeue();
+bool ProfilerEventsProcessor::ProcessOneSample() {
+ if (!ticks_from_vm_buffer_.IsEmpty()
+ && ticks_from_vm_buffer_.Peek()->order ==
+ last_processed_code_event_id_) {
+ TickSampleEventRecord record;
+ ticks_from_vm_buffer_.Dequeue(&record);
+ generator_->RecordTickSample(record.sample);
+ return false;
}
-}
-
-void ProfilerEventsProcessor::ProcessEventsAndDoSample() {
- ElapsedTimer timer;
- timer.Start();
- // Keep processing existing events until we need to do next sample.
- while (!timer.HasExpired(period_)) {
- if (ProcessTicks()) {
- // All ticks of the current dequeue_order are processed,
- // proceed to the next code event.
- ProcessCodeEvent();
- }
- }
- // Schedule next sample. sampler_ is NULL in tests.
- if (sampler_) sampler_->DoSample();
+ const TickSampleEventRecord* record = ticks_buffer_.StartDequeue();
loislo 2013/09/04 14:35:37 please rename StartDequeue to peek and FinishDeque
+ if (record == NULL) return true;
+ if (record->order != last_processed_code_event_id_) return true;
+ generator_->RecordTickSample(record->sample);
+ ticks_buffer_.FinishDequeue();
+ return false;
}
void ProfilerEventsProcessor::Run() {
while (running_) {
- ProcessEventsAndDoSample();
+ ElapsedTimer timer;
+ timer.Start();
+ // Keep processing existing events until we need to do next sample.
+ do {
+ if (ProcessOneSample()) {
+ // All ticks of the current last_processed_code_event_id_ are
+ // processed, proceed to the next code event.
+ ProcessCodeEvent();
+ }
+ } while (!timer.HasExpired(period_));
+
+ // Schedule next sample. sampler_ is NULL in tests.
+ if (sampler_) sampler_->DoSample();
}
// Process remaining tick events.
do {
- ProcessTicks();
+ while (!ProcessOneSample());
} while (ProcessCodeEvent());
}
« no previous file with comments | « src/cpu-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698