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

Side by Side Diff: src/counters.h

Issue 2342643004: [Tracing] Remove unnecessary memory allocation in runtime call stats. (Closed)
Patch Set: rebase Created 4 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 | « no previous file | src/counters.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 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/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 // parent. 784 // parent.
785 static void Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer); 785 static void Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer);
786 786
787 // Set counter id for the innermost measurement. It can be used to refine 787 // Set counter id for the innermost measurement. It can be used to refine
788 // event kind when a runtime entry counter is too generic. 788 // event kind when a runtime entry counter is too generic.
789 static void CorrectCurrentCounterId(RuntimeCallStats* stats, 789 static void CorrectCurrentCounterId(RuntimeCallStats* stats,
790 CounterId counter_id); 790 CounterId counter_id);
791 791
792 void Reset(); 792 void Reset();
793 V8_NOINLINE void Print(std::ostream& os); 793 V8_NOINLINE void Print(std::ostream& os);
794 V8_NOINLINE const char* Dump(); 794 V8_NOINLINE std::string Dump();
795 795
796 RuntimeCallStats() { 796 RuntimeCallStats() {
797 Reset(); 797 Reset();
798 in_use_ = false; 798 in_use_ = false;
799 } 799 }
800 800
801 RuntimeCallTimer* current_timer() { return current_timer_; } 801 RuntimeCallTimer* current_timer() { return current_timer_; }
802 bool InUse() { return in_use_; } 802 bool InUse() { return in_use_; }
803 803
804 private: 804 private:
805 std::stringstream buffer_; 805 std::stringstream buffer_;
806 std::unique_ptr<char[]> buffer_c_str_;
807 size_t len_ = 0;
808 // Counter to track recursive time events. 806 // Counter to track recursive time events.
809 RuntimeCallTimer* current_timer_ = NULL; 807 RuntimeCallTimer* current_timer_ = NULL;
810 // Used to track nested tracing scopes. 808 // Used to track nested tracing scopes.
811 bool in_use_; 809 bool in_use_;
812 }; 810 };
813 811
814 #define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \ 812 #define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \
815 do { \ 813 do { \
816 if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || \ 814 if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || \
817 FLAG_runtime_call_stats)) { \ 815 FLAG_runtime_call_stats)) { \
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 } 1264 }
1267 1265
1268 Isolate* isolate_ = nullptr; 1266 Isolate* isolate_ = nullptr;
1269 RuntimeCallTimer timer_; 1267 RuntimeCallTimer timer_;
1270 }; 1268 };
1271 1269
1272 } // namespace internal 1270 } // namespace internal
1273 } // namespace v8 1271 } // namespace v8
1274 1272
1275 #endif // V8_COUNTERS_H_ 1273 #endif // V8_COUNTERS_H_
OLDNEW
« no previous file with comments | « no previous file | src/counters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698