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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_HEAP_HISTOGRAM_H_
6 #define VM_HEAP_HISTOGRAM_H_
7
8 #include "platform/assert.h"
9 #include "vm/flags.h"
10 #include "vm/raw_object.h"
11 #include "vm/globals.h"
12
13 namespace dart {
14
15 DECLARE_FLAG(bool, print_object_histogram);
16
17 // ObjectHistogram is used to compute an average object histogram over
18 // the lifetime of an isolate and then print the histogram when the isolate
19 // is shut down. Information is gathered at the backedge of each major GC event.
ahe 2013/06/12 11:24:01 backedge -> back-edge or back edge.
bakster 2013/06/12 11:34:21 Done.
20 // When an object histogram is collected for an isolate, an extra major GC is
21 // performed just prior to shutdown.
22 class ObjectHistogram {
23 public:
24 explicit ObjectHistogram(Isolate* isolate);
25 ~ObjectHistogram();
26
27 // Called when a new class is registered in the isoalte.
ahe 2013/06/12 11:24:01 isoalte -> isolate.
bakster 2013/06/12 11:34:21 Done.
28 void RegisterClass(const Class& cls);
29
30 // Collect sample for the histogram. Called at backedge of major GC.
ahe 2013/06/12 11:24:01 backedge -> back-edge or back edge.
bakster 2013/06/12 11:34:21 Done.
31 void Collect();
32
33 // Print the histogram on stdout.
34 void Print();
35
36 private:
37 // Add obj to histogram
38 void Add(RawObject* obj);
39
40 // For each class an Element keeps track of the accounting.
41 struct Element {
42 void Add(int s) {
43 count++;
44 size += s;
45 }
46 int class_id;
47 int count;
48 int size;
49 };
50
51 // Compare function for sorting result.
52 static int compare(const Element** a, const Element** b);
53
54 int major_gc_count_;
55 int table_length_;
56 Element* table_;
57 Isolate* isolate_;
58
59 friend class ObjectHistogramVisitor;
60
61 DISALLOW_COPY_AND_ASSIGN(ObjectHistogram);
62 };
63
64 } // namespace dart
65
66 #endif // VM_HEAP_HISTOGRAM_H_
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/heap_histogram.cc » ('j') | runtime/vm/heap_histogram.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698