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

Unified Diff: tools/tickprocessor.js

Issue 267077: Add initial semi-working producers profile. (Closed)
Patch Set: Comments addressed Created 11 years, 2 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/log.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/tickprocessor.js
diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js
index 84f0eea580d10fcef2ad01d15da638f782cc1bdc..fd23987d9f399082ad4707ba41151c5d412976fa 100644
--- a/tools/tickprocessor.js
+++ b/tools/tickprocessor.js
@@ -75,7 +75,18 @@ function TickProcessor(
'tick': { parsers: [this.createAddressParser('code'),
this.createAddressParser('stack'), parseInt, 'var-args'],
processor: this.processTick, backrefs: true },
+ 'heap-sample-begin': { parsers: [null, null, parseInt],
+ processor: this.processHeapSampleBegin },
+ 'heap-sample-end': { parsers: [null, null],
+ processor: this.processHeapSampleEnd },
+ 'heap-js-prod-item': { parsers: [null, 'var-args'],
+ processor: this.processJSProducer, backrefs: true },
+ // Ignored events.
'profiler': null,
+ 'heap-sample-stats': null,
+ 'heap-sample-item': null,
+ 'heap-js-cons-item': null,
+ 'heap-js-ret-item': null,
// Obsolete row types.
'code-allocate': null,
'begin-code-region': null,
@@ -113,6 +124,9 @@ function TickProcessor(
// Count each tick as a time unit.
this.viewBuilder_ = new devtools.profiler.ViewBuilder(1);
this.lastLogFileName_ = null;
+
+ this.generation_ = 1;
+ this.currentProducerProfile_ = null;
};
inherits(TickProcessor, devtools.profiler.LogReader);
@@ -220,6 +234,41 @@ TickProcessor.prototype.processTick = function(pc, sp, vmState, stack) {
};
+TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
+ if (space != 'Heap') return;
+ this.currentProducerProfile_ = new devtools.profiler.CallTree();
+};
+
+
+TickProcessor.prototype.processHeapSampleEnd = function(space, state) {
+ if (space != 'Heap' || !this.currentProducerProfile_) return;
+
+ print('Generation ' + this.generation_ + ':');
+ var tree = this.currentProducerProfile_;
+ tree.computeTotalWeights();
+ var producersView = this.viewBuilder_.buildView(tree);
+ // Sort by total time, desc, then by name, desc.
+ producersView.sort(function(rec1, rec2) {
+ return rec2.totalTime - rec1.totalTime ||
+ (rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
+ this.printHeavyProfile(producersView.head.children);
+
+ this.currentProducerProfile_ = null;
+ this.generation_++;
+};
+
+
+TickProcessor.prototype.processJSProducer = function(constructor, stack) {
+ if (!this.currentProducerProfile_) return;
+ if (stack.length == 0) return;
+ var first = stack.shift();
+ var processedStack =
+ this.profile_.resolveAndFilterFuncs_(this.processStack(first, stack));
+ processedStack.unshift(constructor);
+ this.currentProducerProfile_.addPath(processedStack);
+};
+
+
TickProcessor.prototype.printStatistics = function() {
print('Statistical profiling result from ' + this.lastLogFileName_ +
', (' + this.ticks_.total +
« no previous file with comments | « src/log.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698