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

Unified Diff: runtime/vm/class_table.h

Issue 173013004: Add accumulator to allocation profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
Index: runtime/vm/class_table.h
diff --git a/runtime/vm/class_table.h b/runtime/vm/class_table.h
index c20e1b70665b6ca71fe444fb99bfffcdacecbddc..dccc8f730325ffd1c261c918c57744d180eaf7fb 100644
--- a/runtime/vm/class_table.h
+++ b/runtime/vm/class_table.h
@@ -17,43 +17,76 @@ class JSONStream;
class ObjectPointerVisitor;
class RawClass;
+template<typename T>
+class AllocStats {
+ public:
+ T new_count;
+ T new_size;
+ T old_count;
+ T old_size;
+
+ void ResetNew() {
+ new_count = 0;
+ new_size = 0;
+ }
+
+ void AddNew(T size) {
+ new_count++;
+ new_size += size;
+ }
+
+ void ResetOld() {
+ old_count = 0;
+ old_size = 0;
+ }
+
+ void AddOld(T size) {
+ old_count++;
+ old_size += size;
+ }
+
+ void Reset() {
+ new_count = 0;
+ new_size = 0;
+ old_count = 0;
+ old_size = 0;
+ }
+};
class ClassHeapStats {
public:
- // Total allocated before GC.
- intptr_t allocated_before_gc_old_space;
- intptr_t allocated_before_gc_new_space;
- intptr_t allocated_size_before_gc_old_space;
- intptr_t allocated_size_before_gc_new_space;
-
+ // Snapshot before GC.
+ AllocStats<intptr_t> pre_gc;
// Live after GC.
- intptr_t live_after_gc_old_space;
- intptr_t live_after_gc_new_space;
- intptr_t live_size_after_gc_old_space;
- intptr_t live_size_after_gc_new_space;
-
- // Allocated since GC.
- intptr_t allocated_since_gc_new_space;
- intptr_t allocated_since_gc_old_space;
- intptr_t allocated_size_since_gc_new_space;
- intptr_t allocated_size_since_gc_old_space;
+ AllocStats<intptr_t> post_gc;
+ // Allocations since the last GC.
+ AllocStats<intptr_t> recent;
+ // Accumulated (across GC) allocations .
+ AllocStats<int64_t> accumulated;
+ // Snapshot of recent at the time of the last reset.
+ AllocStats<intptr_t> last_reset;
static intptr_t allocated_since_gc_new_space_offset() {
- return OFFSET_OF(ClassHeapStats, allocated_since_gc_new_space);
+ return OFFSET_OF(ClassHeapStats, recent) +
+ OFFSET_OF(AllocStats<intptr_t>, new_count);
}
static intptr_t allocated_since_gc_old_space_offset() {
- return OFFSET_OF(ClassHeapStats, allocated_since_gc_old_space);
+ return OFFSET_OF(ClassHeapStats, recent) +
+ OFFSET_OF(AllocStats<intptr_t>, old_count);
}
static intptr_t allocated_size_since_gc_new_space_offset() {
- return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_new_space);
+ return OFFSET_OF(ClassHeapStats, recent) +
+ OFFSET_OF(AllocStats<intptr_t>, new_size);
}
static intptr_t allocated_size_since_gc_old_space_offset() {
- return OFFSET_OF(ClassHeapStats, allocated_size_since_gc_old_space);
+ return OFFSET_OF(ClassHeapStats, recent) +
+ OFFSET_OF(AllocStats<intptr_t>, old_size);
}
void Initialize();
void ResetAtNewGC();
void ResetAtOldGC();
+ void ResetAccumulator();
void UpdateSize(intptr_t instance_size);
void PrintTOJSONArray(const Class& cls, JSONArray* array);
};
@@ -113,6 +146,7 @@ class ClassTable {
void AllocationProfilePrintToJSONStream(JSONStream* stream);
+ void ResetAllocationAccumulators();
private:
friend class MarkingVisitor;
« no previous file with comments | « runtime/bin/vmservice/client/lib/src/observatory_elements/heap_profile.html ('k') | runtime/vm/class_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698