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

Side by Side Diff: runtime/vm/timeline.cc

Issue 1362503002: Add global timeline stream overrides (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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.h ('k') | no next file » | 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 <cstdlib> 5 #include <cstdlib>
6 6
7 #include "vm/atomic.h" 7 #include "vm/atomic.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/json_stream.h" 9 #include "vm/json_stream.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 21 matching lines...) Expand all
32 const bool use_ring_recorder = true; 32 const bool use_ring_recorder = true;
33 // Some flags require that we use the endless recorder. 33 // Some flags require that we use the endless recorder.
34 const bool use_endless_recorder = 34 const bool use_endless_recorder =
35 (FLAG_timeline_dir != NULL) || FLAG_timing; 35 (FLAG_timeline_dir != NULL) || FLAG_timing;
36 if (use_endless_recorder) { 36 if (use_endless_recorder) {
37 recorder_ = new TimelineEventEndlessRecorder(); 37 recorder_ = new TimelineEventEndlessRecorder();
38 } else if (use_ring_recorder) { 38 } else if (use_ring_recorder) {
39 recorder_ = new TimelineEventRingRecorder(); 39 recorder_ = new TimelineEventRingRecorder();
40 } 40 }
41 vm_stream_ = new TimelineStream(); 41 vm_stream_ = new TimelineStream();
42 vm_stream_->Init("VM", EnableStreamByDefault("VM")); 42 vm_stream_->Init("VM", EnableStreamByDefault("VM"), NULL);
43 // Global overrides.
44 #define ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \
45 stream_##name##_enabled_ = false;
46 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT)
47 #undef ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT
43 } 48 }
44 49
45 50
46 void Timeline::Shutdown() { 51 void Timeline::Shutdown() {
47 ASSERT(recorder_ != NULL); 52 ASSERT(recorder_ != NULL);
48 if (FLAG_timeline_dir != NULL) { 53 if (FLAG_timeline_dir != NULL) {
49 recorder_->WriteTo(FLAG_timeline_dir); 54 recorder_->WriteTo(FLAG_timeline_dir);
50 } 55 }
51 delete recorder_; 56 delete recorder_;
52 recorder_ = NULL; 57 recorder_ = NULL;
(...skipping 15 matching lines...) Expand all
68 73
69 TimelineStream* Timeline::GetVMStream() { 74 TimelineStream* Timeline::GetVMStream() {
70 ASSERT(vm_stream_ != NULL); 75 ASSERT(vm_stream_ != NULL);
71 return vm_stream_; 76 return vm_stream_;
72 } 77 }
73 78
74 79
75 TimelineEventRecorder* Timeline::recorder_ = NULL; 80 TimelineEventRecorder* Timeline::recorder_ = NULL;
76 TimelineStream* Timeline::vm_stream_ = NULL; 81 TimelineStream* Timeline::vm_stream_ = NULL;
77 82
83 #define ISOLATE_TIMELINE_STREAM_DEFINE_FLAG(name, enabled_by_default) \
84 bool Timeline::stream_##name##_enabled_ = false;
85 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DEFINE_FLAG)
86 #undef ISOLATE_TIMELINE_STREAM_DEFINE_FLAG
87
78 TimelineEvent::TimelineEvent() 88 TimelineEvent::TimelineEvent()
79 : timestamp0_(0), 89 : timestamp0_(0),
80 timestamp1_(0), 90 timestamp1_(0),
81 arguments_(NULL), 91 arguments_(NULL),
82 arguments_length_(0), 92 arguments_length_(0),
83 state_(0), 93 state_(0),
84 label_(NULL), 94 label_(NULL),
85 category_(""), 95 category_(""),
86 thread_(OSThread::kInvalidThreadId) { 96 thread_(OSThread::kInvalidThreadId) {
87 } 97 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (timestamp1_ == 0) { 314 if (timestamp1_ == 0) {
305 // This duration is still open, use current time as end. 315 // This duration is still open, use current time as end.
306 return OS::GetCurrentTimeMicros() - timestamp0_; 316 return OS::GetCurrentTimeMicros() - timestamp0_;
307 } 317 }
308 return timestamp1_ - timestamp0_; 318 return timestamp1_ - timestamp0_;
309 } 319 }
310 320
311 321
312 TimelineStream::TimelineStream() 322 TimelineStream::TimelineStream()
313 : name_(NULL), 323 : name_(NULL),
314 enabled_(false) { 324 enabled_(false),
325 globally_enabled_(NULL) {
315 } 326 }
316 327
317 328
318 void TimelineStream::Init(const char* name, bool enabled) { 329 void TimelineStream::Init(const char* name,
330 bool enabled,
331 const bool* globally_enabled) {
319 name_ = name; 332 name_ = name;
320 enabled_ = enabled; 333 enabled_ = enabled;
334 globally_enabled_ = globally_enabled;
321 } 335 }
322 336
323 337
324 TimelineEvent* TimelineStream::StartEvent() { 338 TimelineEvent* TimelineStream::StartEvent() {
325 TimelineEventRecorder* recorder = Timeline::recorder(); 339 TimelineEventRecorder* recorder = Timeline::recorder();
326 if (!enabled_ || (recorder == NULL)) { 340 if (!Enabled() || (recorder == NULL)) {
327 return NULL; 341 return NULL;
328 } 342 }
329 ASSERT(name_ != NULL); 343 ASSERT(name_ != NULL);
330 TimelineEvent* event = recorder->StartEvent(); 344 TimelineEvent* event = recorder->StartEvent();
331 if (event != NULL) { 345 if (event != NULL) {
332 event->StreamInit(this); 346 event->StreamInit(this);
333 } 347 }
334 return event; 348 return event;
335 } 349 }
336 350
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 863
850 864
851 TimelineEventBlock* TimelineEventBlockIterator::Next() { 865 TimelineEventBlock* TimelineEventBlockIterator::Next() {
852 ASSERT(current_ != NULL); 866 ASSERT(current_ != NULL);
853 TimelineEventBlock* r = current_; 867 TimelineEventBlock* r = current_;
854 current_ = current_->next(); 868 current_ = current_->next();
855 return r; 869 return r;
856 } 870 }
857 871
858 } // namespace dart 872 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/timeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698