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

Unified Diff: runtime/vm/timeline_analysis.cc

Issue 1297443002: Improve timeline iterators and tests (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
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 | « runtime/vm/timeline_analysis.h ('k') | runtime/vm/timeline_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/timeline_analysis.cc
diff --git a/runtime/vm/timeline_analysis.cc b/runtime/vm/timeline_analysis.cc
index 9ca667812b0333ff6ad8e6e3183957e3f751343f..34bedda4bf06c973163a1e8201621528f17129a5 100644
--- a/runtime/vm/timeline_analysis.cc
+++ b/runtime/vm/timeline_analysis.cc
@@ -40,6 +40,63 @@ void TimelineAnalysisThread::Finalize() {
}
+TimelineAnalysisThreadEventIterator::TimelineAnalysisThreadEventIterator(
+ TimelineAnalysisThread* thread) {
+ Reset(thread);
+}
+
+
+TimelineAnalysisThreadEventIterator::~TimelineAnalysisThreadEventIterator() {
+ Reset(NULL);
+}
+
+
+void TimelineAnalysisThreadEventIterator::Reset(
+ TimelineAnalysisThread* thread) {
+ current_ = NULL;
+ thread_ = thread;
+ block_cursor_ = 0;
+ event_cursor_ = 0;
+ if (thread_ == NULL) {
+ return;
+ }
+ if (thread_->NumBlocks() == 0) {
+ return;
+ }
+ TimelineEventBlock* block = thread_->At(block_cursor_);
+ ASSERT(!block->IsEmpty());
+ current_ = block->At(event_cursor_++);
+}
+
+
+bool TimelineAnalysisThreadEventIterator::HasNext() const {
+ return current_ != NULL;
+}
+
+
+TimelineEvent* TimelineAnalysisThreadEventIterator::Next() {
+ ASSERT(current_ != NULL);
+ TimelineEvent* r = current_;
+ current_ = NULL;
+
+ TimelineEventBlock* block = thread_->At(block_cursor_);
+ if (event_cursor_ == block->length()) {
+ // Reached the end of this block, move to the next.
+ block_cursor_++;
+ if (block_cursor_ == thread_->NumBlocks()) {
+ // Exhausted our supply of blocks.
+ return r;
+ }
+ // Grab next block.
+ block = thread_->At(block_cursor_);
+ event_cursor_ = 0;
+ ASSERT(!block->IsEmpty());
+ }
+ current_ = block->At(event_cursor_++);
+ return r;
+}
+
+
TimelineAnalysis::TimelineAnalysis(Zone* zone,
Isolate* isolate,
TimelineEventRecorder* recorder)
@@ -91,8 +148,8 @@ TimelineAnalysisThread* TimelineAnalysis::GetOrAddThread(ThreadId tid) {
void TimelineAnalysis::DiscoverThreads() {
TimelineEventBlockIterator it(recorder_);
- while (it.Next()) {
- TimelineEventBlock* block = it.current();
+ while (it.HasNext()) {
+ TimelineEventBlock* block = it.Next();
ASSERT(block != NULL);
if (block->IsEmpty()) {
// Skip empty blocks.
@@ -136,4 +193,8 @@ TimelinePauses::TimelinePauses(Zone* zone,
: TimelineAnalysis(zone, isolate, recorder) {
}
+
+void TimelinePauses::CalculatePauseTimes() {
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/timeline_analysis.h ('k') | runtime/vm/timeline_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698