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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/timeline.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 #ifndef VM_TIMELINE_H_ 5 #ifndef VM_TIMELINE_H_
6 #define VM_TIMELINE_H_ 6 #define VM_TIMELINE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/bitfield.h" 9 #include "vm/bitfield.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 "Compile" suffix); \ 327 "Compile" suffix); \
328 if (tds.enabled()) { \ 328 if (tds.enabled()) { \
329 tds.SetNumArguments(1); \ 329 tds.SetNumArguments(1); \
330 tds.CopyArgument( \ 330 tds.CopyArgument( \
331 0, \ 331 0, \
332 "function", \ 332 "function", \
333 const_cast<char*>(function.ToLibNamePrefixedQualifiedCString())); \ 333 const_cast<char*>(function.ToLibNamePrefixedQualifiedCString())); \
334 } 334 }
335 335
336 336
337 class TimelineDurationScope : public StackResource { 337 // See |TimelineDurationScope| and |TimelineBeginEndScope|.
338 class TimelineEventScope : public StackResource {
338 public: 339 public:
339 TimelineDurationScope(TimelineStream* stream,
340 const char* label);
341
342 TimelineDurationScope(Thread* thread,
343 TimelineStream* stream,
344 const char* label);
345
346 ~TimelineDurationScope();
347
348 bool enabled() const { 340 bool enabled() const {
349 return enabled_; 341 return enabled_;
350 } 342 }
351 343
352 void SetNumArguments(intptr_t length); 344 void SetNumArguments(intptr_t length);
353 345
354 void SetArgument(intptr_t i, const char* name, char* argument); 346 void SetArgument(intptr_t i, const char* name, char* argument);
355 347
356 void CopyArgument(intptr_t i, const char* name, const char* argument); 348 void CopyArgument(intptr_t i, const char* name, const char* argument);
357 349
358 void FormatArgument(intptr_t i, 350 void FormatArgument(intptr_t i,
359 const char* name, 351 const char* name,
360 const char* fmt, ...) PRINTF_ATTRIBUTE(4, 5); 352 const char* fmt, ...) PRINTF_ATTRIBUTE(4, 5);
361 353
354 protected:
355 TimelineEventScope(TimelineStream* stream,
356 const char* label);
357
358 TimelineEventScope(Thread* thread,
359 TimelineStream* stream,
360 const char* label);
361
362 bool ShouldEmitEvent() const {
363 return enabled_;
364 }
365
366 const char* label() const {
367 return label_;
368 }
369
370 TimelineStream* stream() const {
371 return stream_;
372 }
373
374 virtual ~TimelineEventScope();
375
376 void StealArguments(TimelineEvent* event);
377
362 private: 378 private:
363 void Init(); 379 void Init();
364 void FreeArguments(); 380 void FreeArguments();
365 381
366 int64_t timestamp_;
367 TimelineStream* stream_; 382 TimelineStream* stream_;
368 const char* label_; 383 const char* label_;
369 TimelineEventArgument* arguments_; 384 TimelineEventArgument* arguments_;
370 intptr_t arguments_length_; 385 intptr_t arguments_length_;
371 bool enabled_; 386 bool enabled_;
372 387
388 DISALLOW_COPY_AND_ASSIGN(TimelineEventScope);
389 };
390
391
392 class TimelineDurationScope : public TimelineEventScope {
393 public:
394 TimelineDurationScope(TimelineStream* stream,
395 const char* label);
396
397 TimelineDurationScope(Thread* thread,
398 TimelineStream* stream,
399 const char* label);
400
401 ~TimelineDurationScope();
402
403 private:
404 int64_t timestamp_;
405
373 DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope); 406 DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope);
374 }; 407 };
375 408
376 409
410 class TimelineBeginEndScope : public TimelineEventScope {
411 public:
412 TimelineBeginEndScope(TimelineStream* stream,
413 const char* label);
414
415 TimelineBeginEndScope(Thread* thread,
416 TimelineStream* stream,
417 const char* label);
418
419 ~TimelineBeginEndScope();
420
421 private:
422 void EmitBegin();
423 void EmitEnd();
424
425 DISALLOW_COPY_AND_ASSIGN(TimelineBeginEndScope);
426 };
427
428
377 // A block of |TimelineEvent|s. Not thread safe. 429 // A block of |TimelineEvent|s. Not thread safe.
378 class TimelineEventBlock { 430 class TimelineEventBlock {
379 public: 431 public:
380 static const intptr_t kBlockSize = 64; 432 static const intptr_t kBlockSize = 64;
381 433
382 explicit TimelineEventBlock(intptr_t index); 434 explicit TimelineEventBlock(intptr_t index);
383 ~TimelineEventBlock(); 435 ~TimelineEventBlock();
384 436
385 TimelineEventBlock* next() const { 437 TimelineEventBlock* next() const {
386 return next_; 438 return next_;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 705
654 private: 706 private:
655 TimelineEventBlock* current_; 707 TimelineEventBlock* current_;
656 TimelineEventRecorder* recorder_; 708 TimelineEventRecorder* recorder_;
657 }; 709 };
658 710
659 711
660 } // namespace dart 712 } // namespace dart
661 713
662 #endif // VM_TIMELINE_H_ 714 #endif // VM_TIMELINE_H_
OLDNEW
« 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