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

Unified Diff: runtime/vm/timeline.h

Issue 1529613002: Add TimelineBeginEndScope helper class (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/timeline.h
diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h
index fa55f75f884a75df9dfb4385866ed55c59047ec4..47d2439567b56b1308e5bdf4014f565abcd7f7d1 100644
--- a/runtime/vm/timeline.h
+++ b/runtime/vm/timeline.h
@@ -334,17 +334,9 @@ class TimelineStream {
}
-class TimelineDurationScope : public StackResource {
+// See |TimelineDurationScope| and |TimelineBeginEndScope|.
+class TimelineEventScope : public StackResource {
public:
- TimelineDurationScope(TimelineStream* stream,
- const char* label);
-
- TimelineDurationScope(Thread* thread,
- TimelineStream* stream,
- const char* label);
-
- ~TimelineDurationScope();
-
bool enabled() const {
return enabled_;
}
@@ -359,21 +351,81 @@ class TimelineDurationScope : public StackResource {
const char* name,
const char* fmt, ...) PRINTF_ATTRIBUTE(4, 5);
+ protected:
+ TimelineEventScope(TimelineStream* stream,
+ const char* label);
+
+ TimelineEventScope(Thread* thread,
+ TimelineStream* stream,
+ const char* label);
+
+ bool ShouldEmitEvent() const {
+ return enabled_;
+ }
+
+ const char* label() const {
+ return label_;
+ }
+
+ TimelineStream* stream() const {
+ return stream_;
+ }
+
+ virtual ~TimelineEventScope();
+
+ void StealArguments(TimelineEvent* event);
+
private:
void Init();
void FreeArguments();
- int64_t timestamp_;
TimelineStream* stream_;
const char* label_;
TimelineEventArgument* arguments_;
intptr_t arguments_length_;
bool enabled_;
+ DISALLOW_COPY_AND_ASSIGN(TimelineEventScope);
+};
+
+
+class TimelineDurationScope : public TimelineEventScope {
+ public:
+ TimelineDurationScope(TimelineStream* stream,
+ const char* label);
+
+ TimelineDurationScope(Thread* thread,
+ TimelineStream* stream,
+ const char* label);
+
+ ~TimelineDurationScope();
+
+ private:
+ int64_t timestamp_;
+
DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope);
};
+class TimelineBeginEndScope : public TimelineEventScope {
+ public:
+ TimelineBeginEndScope(TimelineStream* stream,
+ const char* label);
+
+ TimelineBeginEndScope(Thread* thread,
+ TimelineStream* stream,
+ const char* label);
+
+ ~TimelineBeginEndScope();
+
+ private:
+ void EmitBegin();
+ void EmitEnd();
+
+ DISALLOW_COPY_AND_ASSIGN(TimelineBeginEndScope);
+};
+
+
// A block of |TimelineEvent|s. Not thread safe.
class TimelineEventBlock {
public:
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698