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

Side by Side Diff: src/counters.h

Issue 2472193002: [profiler] Introduce lightweight mode for Rutime Call Stats collection. (Closed)
Patch Set: . Created 4 years, 1 month 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 | src/tracing/tracing-category-observer.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COUNTERS_H_ 5 #ifndef V8_COUNTERS_H_
6 #define V8_COUNTERS_H_ 6 #define V8_COUNTERS_H_
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/base/atomic-utils.h" 10 #include "src/base/atomic-utils.h"
11 #include "src/base/platform/elapsed-timer.h" 11 #include "src/base/platform/elapsed-timer.h"
12 #include "src/base/platform/time.h" 12 #include "src/base/platform/time.h"
13 #include "src/builtins/builtins.h" 13 #include "src/builtins/builtins.h"
14 #include "src/globals.h" 14 #include "src/globals.h"
15 #include "src/isolate.h" 15 #include "src/isolate.h"
16 #include "src/objects.h" 16 #include "src/objects.h"
17 #include "src/runtime/runtime.h" 17 #include "src/runtime/runtime.h"
18 #include "src/tracing/trace-event.h" 18 #include "src/tracing/trace-event.h"
19 #include "src/tracing/traced-value.h" 19 #include "src/tracing/traced-value.h"
20 #include "src/tracing/tracing-category-observer.h"
20 21
21 namespace v8 { 22 namespace v8 {
22 namespace internal { 23 namespace internal {
23 24
24 // StatsCounters is an interface for plugging into external 25 // StatsCounters is an interface for plugging into external
25 // counters for monitoring. Counters can be looked up and 26 // counters for monitoring. Counters can be looked up and
26 // manipulated by name. 27 // manipulated by name.
27 28
28 class StatsTable { 29 class StatsTable {
29 public: 30 public:
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 RuntimeCallCounter* counter() { return counter_; } 501 RuntimeCallCounter* counter() { return counter_; }
501 base::ElapsedTimer timer() { return timer_; } 502 base::ElapsedTimer timer() { return timer_; }
502 RuntimeCallTimer* parent() const { return parent_.Value(); } 503 RuntimeCallTimer* parent() const { return parent_.Value(); }
503 504
504 private: 505 private:
505 friend class RuntimeCallStats; 506 friend class RuntimeCallStats;
506 507
507 inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent) { 508 inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent) {
508 counter_ = counter; 509 counter_ = counter;
509 parent_.SetValue(parent); 510 parent_.SetValue(parent);
510 timer_.Start(); 511 if (FLAG_runtime_stats !=
512 v8::tracing::TracingCategoryObserver::ENABLED_BY_SAMPLING) {
513 timer_.Start();
514 }
511 } 515 }
512 516
513 inline RuntimeCallTimer* Stop() { 517 inline RuntimeCallTimer* Stop() {
518 if (!timer_.IsStarted()) return parent();
514 base::TimeDelta delta = timer_.Elapsed(); 519 base::TimeDelta delta = timer_.Elapsed();
515 timer_.Stop(); 520 timer_.Stop();
516 counter_->count++; 521 counter_->count++;
517 counter_->time += delta; 522 counter_->time += delta;
518 if (parent()) { 523 if (parent()) {
519 // Adjust parent timer so that it does not include sub timer's time. 524 // Adjust parent timer so that it does not include sub timer's time.
520 parent()->counter_->time -= delta; 525 parent()->counter_->time -= delta;
521 } 526 }
522 return parent(); 527 return parent();
523 } 528 }
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 } 1308 }
1304 1309
1305 Isolate* isolate_ = nullptr; 1310 Isolate* isolate_ = nullptr;
1306 RuntimeCallTimer timer_; 1311 RuntimeCallTimer timer_;
1307 }; 1312 };
1308 1313
1309 } // namespace internal 1314 } // namespace internal
1310 } // namespace v8 1315 } // namespace v8
1311 1316
1312 #endif // V8_COUNTERS_H_ 1317 #endif // V8_COUNTERS_H_
OLDNEW
« no previous file with comments | « no previous file | src/tracing/tracing-category-observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698