Index: src/cpu-profiler.cc |
diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc |
index e54b040d44ae4aa1be3bf8d4aacb4774d62498c5..537ef44797a479b54b9c0db0d4642969b2336857 100644 |
--- a/src/cpu-profiler.cc |
+++ b/src/cpu-profiler.cc |
@@ -104,45 +104,49 @@ bool ProfilerEventsProcessor::ProcessCodeEvent() { |
} |
-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; |
+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_.Peek(); |
+ 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_.Remove(); |
} |
+} |
- const TickSampleEventRecord* record = ticks_buffer_.Peek(); |
- if (record == NULL) return true; |
- if (record->order != last_processed_code_event_id_) return true; |
- generator_->RecordTickSample(record->sample); |
- ticks_buffer_.Remove(); |
- 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(); |
} |
void ProfilerEventsProcessor::Run() { |
while (running_) { |
- 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(); |
+ ProcessEventsAndDoSample(); |
} |
// Process remaining tick events. |
do { |
- while (!ProcessOneSample()) {} |
+ ProcessTicks(); |
} while (ProcessCodeEvent()); |
} |