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

Unified Diff: runtime/vm/heap_histogram.h

Issue 16077018: Implemented an averaging object histogram in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « runtime/vm/heap.cc ('k') | runtime/vm/heap_histogram.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap_histogram.h
===================================================================
--- runtime/vm/heap_histogram.h (revision 0)
+++ runtime/vm/heap_histogram.h (revision 0)
@@ -0,0 +1,68 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef VM_HEAP_HISTOGRAM_H_
+#define VM_HEAP_HISTOGRAM_H_
+
+#include "platform/assert.h"
+#include "vm/flags.h"
+#include "vm/globals.h"
+#include "vm/raw_object.h"
+
+namespace dart {
+
+DECLARE_FLAG(bool, print_object_histogram);
+
+// ObjectHistogram is used to compute an average object histogram over
+// the lifetime of an isolate and then print the histogram when the isolate
+// is shut down. Information is gathered at the back-edge of each major GC
+// event. When an object histogram is collected for an isolate, an extra major
+// GC is performed just prior to shutdown.
+class ObjectHistogram {
+ public:
+ explicit ObjectHistogram(Isolate* isolate);
+ ~ObjectHistogram();
+
+ // Called when a new class is registered in the isolate.
+ void RegisterClass(const Class& cls);
+
+ // Collect sample for the histogram. Called at back-edge of major GC.
+ void Collect();
+
+ // Print the histogram on stdout.
+ void Print();
+
+ private:
+ // Add obj to histogram
+ void Add(RawObject* obj);
+
+ // For each class an Element keeps track of the accounting.
+ class Element : public ValueObject {
+ public:
+ void Add(int size) {
+ count_++;
+ size_ += size;
+ }
+ intptr_t class_id_;
+ intptr_t count_;
+ intptr_t size_;
+ };
+
+ // Compare function for sorting result.
+ static int compare(const Element** a, const Element** b);
+
+ intptr_t major_gc_count_;
+ intptr_t table_length_;
+ Element* table_;
+ Isolate* isolate_;
+
+ friend class ObjectHistogramVisitor;
+
+ DISALLOW_COPY_AND_ASSIGN(ObjectHistogram);
+};
+
+} // namespace dart
+
+#endif // VM_HEAP_HISTOGRAM_H_
+
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/heap_histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698