Commit e1f38de7 authored by gdeepti's avatar gdeepti Committed by Commit bot

[Tick processor] Add an option to the tick-processor to print the summary.

 - Print the summary excluding other tick information
 - Add test to verify that summary is printed correctly.

BUG=None
LOG=N

R=machenbach@chromium.org

Review URL: https://codereview.chromium.org/1318933004

Cr-Commit-Position: refs/heads/master@{#30573}
parent 29a2e8f8
Statistical profiling result from v8.log, (13 ticks, 2 unaccounted, 0 excluded).
[Summary]:
ticks total nonlib name
0 0.0% 0.0% JavaScript
5 38.5% 55.6% C++
0 0.0% 0.0% GC
4 30.8% Shared libraries
2 15.4% Unaccounted
......@@ -370,7 +370,7 @@ PrintMonitor.prototype.finish = function() {
function driveTickProcessorTest(
separateIc, ignoreUnknown, stateFilter, logInput, refOutput) {
separateIc, ignoreUnknown, stateFilter, logInput, refOutput, onlySummary) {
// TEST_FILE_NAME must be provided by test runner.
assertEquals('string', typeof TEST_FILE_NAME);
var pathLen = TEST_FILE_NAME.lastIndexOf('/');
......@@ -387,7 +387,10 @@ function driveTickProcessorTest(
undefined,
"0",
"auto,auto",
false);
false,
false,
false,
onlySummary);
var pm = new PrintMonitor(testsPath + refOutput);
tp.processLogFileInTest(testsPath + logInput);
tp.printStatistics();
......@@ -399,19 +402,23 @@ function driveTickProcessorTest(
var testData = {
'Default': [
false, false, null,
'tickprocessor-test.log', 'tickprocessor-test.default'],
'tickprocessor-test.log', 'tickprocessor-test.default', false],
'SeparateIc': [
true, false, null,
'tickprocessor-test.log', 'tickprocessor-test.separate-ic'],
'tickprocessor-test.log', 'tickprocessor-test.separate-ic', false],
'IgnoreUnknown': [
false, true, null,
'tickprocessor-test.log', 'tickprocessor-test.ignore-unknown'],
'tickprocessor-test.log', 'tickprocessor-test.ignore-unknown', false],
'GcState': [
false, false, TickProcessor.VmStates.GC,
'tickprocessor-test.log', 'tickprocessor-test.gc-state'],
'tickprocessor-test.log', 'tickprocessor-test.gc-state', false],
'FunctionInfo': [
false, false, null,
'tickprocessor-test-func-info.log', 'tickprocessor-test.func-info']
'tickprocessor-test-func-info.log', 'tickprocessor-test.func-info',
false],
'OnlySummary': [
false, false, null,
'tickprocessor-test.log', 'tickprocessor-test.only-summary', true]
};
for (var testName in testData) {
print('=== testProcessing-' + testName + ' ===');
......
......@@ -77,6 +77,7 @@ var tickProcessor = new TickProcessor(
params.range,
sourceMap,
params.timedRange,
params.pairwiseTimedRange);
params.pairwiseTimedRange,
params.onlySummary);
tickProcessor.processLogFile(params.logFileName);
tickProcessor.printStatistics();
......@@ -156,7 +156,8 @@ function TickProcessor(
range,
sourceMap,
timedRange,
pairwiseTimedRange) {
pairwiseTimedRange,
onlySummary) {
LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt],
processor: this.processSharedLibrary },
......@@ -247,6 +248,7 @@ function TickProcessor(
this.generation_ = 1;
this.currentProducerProfile_ = null;
this.onlySummary_ = onlySummary;
};
inherits(TickProcessor, LogReader);
......@@ -456,29 +458,30 @@ TickProcessor.prototype.printStatistics = function() {
if (this.ignoreUnknown_) {
totalTicks -= this.ticks_.unaccounted;
}
var printAllTicks = !this.onlySummary_;
// Count library ticks
var flatViewNodes = flatView.head.children;
var self = this;
var libraryTicks = 0;
this.printHeader('Shared libraries');
if(printAllTicks) this.printHeader('Shared libraries');
this.printEntries(flatViewNodes, totalTicks, null,
function(name) { return self.isSharedLibrary(name); },
function(rec) { libraryTicks += rec.selfTime; });
function(rec) { libraryTicks += rec.selfTime; }, printAllTicks);
var nonLibraryTicks = totalTicks - libraryTicks;
var jsTicks = 0;
this.printHeader('JavaScript');
if(printAllTicks) this.printHeader('JavaScript');
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
function(name) { return self.isJsCode(name); },
function(rec) { jsTicks += rec.selfTime; });
function(rec) { jsTicks += rec.selfTime; }, printAllTicks);
var cppTicks = 0;
this.printHeader('C++');
if(printAllTicks) this.printHeader('C++');
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
function(name) { return self.isCppCode(name); },
function(rec) { cppTicks += rec.selfTime; });
function(rec) { cppTicks += rec.selfTime; }, printAllTicks);
this.printHeader('Summary');
this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks);
......@@ -490,25 +493,27 @@ TickProcessor.prototype.printStatistics = function() {
this.ticks_.total, null);
}
print('\n [C++ entry points]:');
print(' ticks cpp total name');
var c_entry_functions = this.profile_.getCEntryProfile();
var total_c_entry = c_entry_functions[0].ticks;
for (var i = 1; i < c_entry_functions.length; i++) {
c = c_entry_functions[i];
this.printLine(c.name, c.ticks, total_c_entry, totalTicks);
}
if(printAllTicks) {
print('\n [C++ entry points]:');
print(' ticks cpp total name');
var c_entry_functions = this.profile_.getCEntryProfile();
var total_c_entry = c_entry_functions[0].ticks;
for (var i = 1; i < c_entry_functions.length; i++) {
c = c_entry_functions[i];
this.printLine(c.name, c.ticks, total_c_entry, totalTicks);
}
this.printHeavyProfHeader();
var heavyProfile = this.profile_.getBottomUpProfile();
var heavyView = this.viewBuilder_.buildView(heavyProfile);
// To show the same percentages as in the flat profile.
heavyView.head.totalTime = totalTicks;
// Sort by total time, desc, then by name, desc.
heavyView.sort(function(rec1, rec2) {
return rec2.totalTime - rec1.totalTime ||
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
this.printHeavyProfile(heavyView.head.children);
this.printHeavyProfHeader();
var heavyProfile = this.profile_.getBottomUpProfile();
var heavyView = this.viewBuilder_.buildView(heavyProfile);
// To show the same percentages as in the flat profile.
heavyView.head.totalTime = totalTicks;
// Sort by total time, desc, then by name, desc.
heavyView.sort(function(rec1, rec2) {
return rec2.totalTime - rec1.totalTime ||
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
this.printHeavyProfile(heavyView.head.children);
}
};
......@@ -600,13 +605,15 @@ TickProcessor.prototype.formatFunctionName = function(funcName) {
};
TickProcessor.prototype.printEntries = function(
profile, totalTicks, nonLibTicks, filterP, callback) {
profile, totalTicks, nonLibTicks, filterP, callback, printAllTicks) {
var that = this;
this.processProfile(profile, filterP, function (rec) {
if (rec.selfTime == 0) return;
callback(rec);
var funcName = that.formatFunctionName(rec.internalFuncName);
that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
if(printAllTicks) {
that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
}
});
};
......@@ -884,7 +891,9 @@ function ArgumentsProcessor(args) {
'--timed-range': ['timedRange', true,
'Ignore ticks before first and after last Date.now() call'],
'--pairwise-timed-range': ['pairwiseTimedRange', true,
'Ignore ticks outside pairs of Date.now() calls']
'Ignore ticks outside pairs of Date.now() calls'],
'--only-summary': ['onlySummary', true,
'Print only tick summary, exclude other information']
};
this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
......@@ -908,7 +917,8 @@ ArgumentsProcessor.DEFAULTS = {
range: 'auto,auto',
distortion: 0,
timedRange: false,
pairwiseTimedRange: false
pairwiseTimedRange: false,
onlySummary: false
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment