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

Unified Diff: runtime/vm/timeline.cc

Issue 1284263002: Start TimelineAnalysis utility (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.h ('k') | runtime/vm/timeline_analysis.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/timeline.cc
diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc
index 5f0448868fa1abf14c9a897418b672f2d47ec9d4..595c0fe135eb5224007e17d95bb8550b6b885175 100644
--- a/runtime/vm/timeline.cc
+++ b/runtime/vm/timeline.cc
@@ -13,7 +13,7 @@
namespace dart {
-DEFINE_FLAG(bool, trace_timeline, false, "Trace timeline code.");
+DEFINE_FLAG(bool, trace_timeline, false, "Trace timeline backend");
DEFINE_FLAG(bool, complete_timeline, false, "Record the complete timeline");
TimelineEvent::TimelineEvent()
@@ -586,4 +586,79 @@ TimelineEvent* TimelineEventBlock::StartEvent() {
return &events_[length_++];
}
+
+ThreadId TimelineEventBlock::thread() const {
+ ASSERT(length_ > 0);
+ return events_[0].thread();
+}
+
+
+int64_t TimelineEventBlock::LowerTimeBound() const {
+ ASSERT(length_ > 0);
+ return events_[0].TimeOrigin();
+}
+
+
+bool TimelineEventBlock::CheckBlock() {
+ if (length() == 0) {
+ return true;
+ }
+
+ // - events in the block come from one thread.
+ ThreadId tid = thread();
+ for (intptr_t i = 0; i < length(); i++) {
+ if (At(i)->thread() != tid) {
+ return false;
+ }
+ }
+
+ // - events have monotonically increasing timestamps.
+ int64_t last_time = LowerTimeBound();
+ for (intptr_t i = 0; i < length(); i++) {
+ if (last_time > At(i)->TimeOrigin()) {
+ return false;
+ }
+ last_time = At(i)->TimeOrigin();
+ }
+
+ return true;
+}
+
+
+TimelineEventBlockIterator::TimelineEventBlockIterator(
+ TimelineEventEndlessRecorder* recorder)
+ : current_(NULL),
+ recorder_(recorder) {
+ if (recorder_ == NULL) {
+ return;
+ }
+ recorder->lock_.Lock();
+}
+
+
+TimelineEventBlockIterator::~TimelineEventBlockIterator() {
+ if (recorder_ == NULL) {
+ return;
+ }
+ recorder_->lock_.Unlock();
+}
+
+
+void TimelineEventBlockIterator::Reset() {
+ current_ = NULL;
+}
+
+
+bool TimelineEventBlockIterator::Next() {
+ if (recorder_ == NULL) {
+ return false;
+ }
+ if (current_ == NULL) {
+ current_ = recorder_->head_;
+ } else {
+ current_ = current_->next();
+ }
+ return current_ != NULL;
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/timeline.h ('k') | runtime/vm/timeline_analysis.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698