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

Unified Diff: src/counters.cc

Issue 1681943002: [counter] Properly measure own-time of runtime counters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2016-02-08_builtins_timer_1678973002
Patch Set: fixing type Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.cc
diff --git a/src/counters.cc b/src/counters.cc
index 709c6fb15d8b73b84c8980c677371977b095e440..b767db5a5ce834f6c98696e8560eaabcaa27fcf1 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -212,10 +212,10 @@ class RuntimeCallStatEntries {
}
}
- void Add(const char* name, base::TimeDelta time, uint32_t count) {
- entries.push_back(Entry(name, time, count));
- total_time += time;
- total_call_count += count;
+ void Add(const char* name, RuntimeCallCounter counter) {
+ entries.push_back(Entry(name, counter.time, counter.count));
+ total_time += counter.time;
+ total_call_count += counter.count;
}
private:
@@ -263,18 +263,38 @@ class RuntimeCallStatEntries {
std::vector<Entry> entries;
};
+void RuntimeCallCounter::Reset() {
+ count = 0;
+ time = base::TimeDelta();
+}
+
+void RuntimeCallStats::Enter(RuntimeCallCounter* counter) {
+ counter->count++;
+ counter->parent_counter = current_counter;
+ current_counter = counter;
+}
+void RuntimeCallStats::Leave(base::TimeDelta time) {
+ RuntimeCallCounter* counter = current_counter;
+ counter->time += time;
+ current_counter = counter->parent_counter;
+ counter->parent_counter = NULL;
+ if (current_counter != NULL) {
+ current_counter->time -= time;
+ }
+}
+
void RuntimeCallStats::Print(std::ostream& os) {
RuntimeCallStatEntries entries;
-#define PRINT_COUNTER(name, nargs, ressize) \
- if (this->Count_Runtime_##name > 0) { \
- entries.Add(#name, this->Time_Runtime_##name, this->Count_Runtime_##name); \
+#define PRINT_COUNTER(name, nargs, ressize) \
+ if (this->Runtime_##name.count > 0) { \
+ entries.Add(#name, this->Runtime_##name); \
}
FOR_EACH_INTRINSIC(PRINT_COUNTER)
#undef PRINT_COUNTER
-#define PRINT_COUNTER(name, type) \
- if (this->Count_Builtin_##name > 0) { \
- entries.Add(#name, this->Time_Builtin_##name, this->Count_Builtin_##name); \
+#define PRINT_COUNTER(name, type) \
+ if (this->Builtin_##name.count > 0) { \
+ entries.Add(#name, this->Builtin_##name); \
}
BUILTIN_LIST_C(PRINT_COUNTER)
#undef PRINT_COUNTER
@@ -282,14 +302,10 @@ void RuntimeCallStats::Print(std::ostream& os) {
}
void RuntimeCallStats::Reset() {
-#define RESET_COUNTER(name, nargs, ressize) \
- Count_Runtime_##name = 0; \
- Time_Runtime_##name = base::TimeDelta();
+#define RESET_COUNTER(name, nargs, ressize) this->Runtime_##name.Reset();
FOR_EACH_INTRINSIC(RESET_COUNTER)
#undef RESET_COUNTER
-#define RESET_COUNTER(name, type) \
- Count_Builtin_##name = 0; \
- Time_Builtin_##name = base::TimeDelta();
+#define RESET_COUNTER(name, type) this->Builtin_##name.Reset();
BUILTIN_LIST_C(RESET_COUNTER)
#undef RESET_COUNTER
}
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698