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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/timeline_analysis.h ('k') | runtime/vm/timeline_test.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 (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/timeline_analysis.h" 5 #include "vm/timeline_analysis.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 22 matching lines...) Expand all
33 ASSERT(*b != NULL); 33 ASSERT(*b != NULL);
34 return (*a)->LowerTimeBound() - (*b)->LowerTimeBound(); 34 return (*a)->LowerTimeBound() - (*b)->LowerTimeBound();
35 } 35 }
36 36
37 37
38 void TimelineAnalysisThread::Finalize() { 38 void TimelineAnalysisThread::Finalize() {
39 blocks_.Sort(CompareBlocksLowerTimeBound); 39 blocks_.Sort(CompareBlocksLowerTimeBound);
40 } 40 }
41 41
42 42
43 TimelineAnalysisThreadEventIterator::TimelineAnalysisThreadEventIterator(
44 TimelineAnalysisThread* thread) {
45 Reset(thread);
46 }
47
48
49 TimelineAnalysisThreadEventIterator::~TimelineAnalysisThreadEventIterator() {
50 Reset(NULL);
51 }
52
53
54 void TimelineAnalysisThreadEventIterator::Reset(
55 TimelineAnalysisThread* thread) {
56 current_ = NULL;
57 thread_ = thread;
58 block_cursor_ = 0;
59 event_cursor_ = 0;
60 if (thread_ == NULL) {
61 return;
62 }
63 if (thread_->NumBlocks() == 0) {
64 return;
65 }
66 TimelineEventBlock* block = thread_->At(block_cursor_);
67 ASSERT(!block->IsEmpty());
68 current_ = block->At(event_cursor_++);
69 }
70
71
72 bool TimelineAnalysisThreadEventIterator::HasNext() const {
73 return current_ != NULL;
74 }
75
76
77 TimelineEvent* TimelineAnalysisThreadEventIterator::Next() {
78 ASSERT(current_ != NULL);
79 TimelineEvent* r = current_;
80 current_ = NULL;
81
82 TimelineEventBlock* block = thread_->At(block_cursor_);
83 if (event_cursor_ == block->length()) {
84 // Reached the end of this block, move to the next.
85 block_cursor_++;
86 if (block_cursor_ == thread_->NumBlocks()) {
87 // Exhausted our supply of blocks.
88 return r;
89 }
90 // Grab next block.
91 block = thread_->At(block_cursor_);
92 event_cursor_ = 0;
93 ASSERT(!block->IsEmpty());
94 }
95 current_ = block->At(event_cursor_++);
96 return r;
97 }
98
99
43 TimelineAnalysis::TimelineAnalysis(Zone* zone, 100 TimelineAnalysis::TimelineAnalysis(Zone* zone,
44 Isolate* isolate, 101 Isolate* isolate,
45 TimelineEventRecorder* recorder) 102 TimelineEventRecorder* recorder)
46 : zone_(zone), 103 : zone_(zone),
47 isolate_(isolate), 104 isolate_(isolate),
48 recorder_(recorder), 105 recorder_(recorder),
49 has_error_(false), 106 has_error_(false),
50 error_msg_(NULL) { 107 error_msg_(NULL) {
51 ASSERT(zone_ != NULL); 108 ASSERT(zone_ != NULL);
52 ASSERT(isolate_ != NULL); 109 ASSERT(isolate_ != NULL);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 141 }
85 // New thread. 142 // New thread.
86 thread = new TimelineAnalysisThread(tid); 143 thread = new TimelineAnalysisThread(tid);
87 threads_.Add(thread); 144 threads_.Add(thread);
88 return thread; 145 return thread;
89 } 146 }
90 147
91 148
92 void TimelineAnalysis::DiscoverThreads() { 149 void TimelineAnalysis::DiscoverThreads() {
93 TimelineEventBlockIterator it(recorder_); 150 TimelineEventBlockIterator it(recorder_);
94 while (it.Next()) { 151 while (it.HasNext()) {
95 TimelineEventBlock* block = it.current(); 152 TimelineEventBlock* block = it.Next();
96 ASSERT(block != NULL); 153 ASSERT(block != NULL);
97 if (block->IsEmpty()) { 154 if (block->IsEmpty()) {
98 // Skip empty blocks. 155 // Skip empty blocks.
99 continue; 156 continue;
100 } 157 }
101 if (!block->CheckBlock()) { 158 if (!block->CheckBlock()) {
102 // Skip bad blocks. 159 // Skip bad blocks.
103 // TODO(johnmccutchan): Make this into an error? 160 // TODO(johnmccutchan): Make this into an error?
104 continue; 161 continue;
105 } 162 }
(...skipping 23 matching lines...) Expand all
129 ASSERT(error_msg_ != NULL); 186 ASSERT(error_msg_ != NULL);
130 } 187 }
131 188
132 189
133 TimelinePauses::TimelinePauses(Zone* zone, 190 TimelinePauses::TimelinePauses(Zone* zone,
134 Isolate* isolate, 191 Isolate* isolate,
135 TimelineEventRecorder* recorder) 192 TimelineEventRecorder* recorder)
136 : TimelineAnalysis(zone, isolate, recorder) { 193 : TimelineAnalysis(zone, isolate, recorder) {
137 } 194 }
138 195
196
197 void TimelinePauses::CalculatePauseTimes() {
198 }
199
139 } // namespace dart 200 } // namespace dart
OLDNEW
« 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