Commit a8582eb2 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] parse-processor improvements

- display script size overview
- color scripts in overview depending on eval, streaming or other scripts
- fix stats to always take own-bytes into accout
- rename all *Time properties to *Duration for consistency
- extract ScriptSource log event into separate method
- support script source events in parse-processor

Bug: chromium:757467, chromium:850038
Change-Id: I227d1d5952ae9e508ab1a01146fcf47f74a3f7ea
Reviewed-on: https://chromium-review.googlesource.com/1117195
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54159}
parent e14699c5
......@@ -1301,40 +1301,20 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
Name* source, int line, int column) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
AppendCodeCreateHeader(msg, tag, code, &timer_);
msg << shared->DebugName() << " " << source << ":" << line << ":" << column
<< kNext << reinterpret_cast<void*>(shared->address()) << kNext
<< ComputeMarker(shared, code);
msg.WriteToLogFile();
{
Log::MessageBuilder msg(log_);
AppendCodeCreateHeader(msg, tag, code, &timer_);
msg << shared->DebugName() << " " << source << ":" << line << ":" << column
<< kNext << reinterpret_cast<void*>(shared->address()) << kNext
<< ComputeMarker(shared, code);
msg.WriteToLogFile();
}
if (!FLAG_log_source_code) return;
Object* script_object = shared->script();
if (!script_object->IsScript()) return;
// Make sure the script is written to the log file.
Script* script = Script::cast(script_object);
int script_id = script->id();
if (logged_source_code_.find(script_id) == logged_source_code_.end()) {
// This script has not been logged yet.
logged_source_code_.insert(script_id);
Object* source_object = script->source();
if (source_object->IsString()) {
String* source_code = String::cast(source_object);
msg << "script" << kNext << script_id << kNext;
// Log the script name.
if (script->name()->IsString()) {
msg << String::cast(script->name()) << kNext;
} else {
msg << "<unknown>" << kNext;
}
// Log the source code.
msg << source_code;
msg.WriteToLogFile();
}
}
if (!EnsureLogScriptSource(script)) return;
// We log source code information in the form:
//
......@@ -1357,10 +1337,11 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
// <function-id> is an index into the <fns> function table
// <fns> is the function table encoded as a sequence of strings
// S<shared-function-info-address>
Log::MessageBuilder msg(log_);
msg << "code-source-info" << kNext
<< reinterpret_cast<void*>(code->InstructionStart()) << kNext << script_id
<< kNext << shared->StartPosition() << kNext << shared->EndPosition()
<< kNext;
<< reinterpret_cast<void*>(code->InstructionStart()) << kNext
<< script->id() << kNext << shared->StartPosition() << kNext
<< shared->EndPosition() << kNext;
SourcePositionTableIterator iterator(code->source_position_table());
bool is_first = true;
......@@ -1624,6 +1605,34 @@ void Logger::ScriptDetails(Script* script) {
msg.WriteToLogFile();
}
bool Logger::EnsureLogScriptSource(Script* script) {
if (!log_->IsEnabled()) return false;
Log::MessageBuilder msg(log_);
// Make sure the script is written to the log file.
int script_id = script->id();
if (logged_source_code_.find(script_id) != logged_source_code_.end()) {
return false;
}
// This script has not been logged yet.
logged_source_code_.insert(script_id);
Object* source_object = script->source();
if (!source_object->IsString()) return false;
String* source_code = String::cast(source_object);
msg << "script-source" << kNext << script_id << kNext;
// Log the script name.
if (script->name()->IsString()) {
msg << String::cast(script->name()) << kNext;
} else {
msg << "<unknown>" << kNext;
}
// Log the source code.
msg << source_code;
msg.WriteToLogFile();
return true;
}
void Logger::RuntimeCallTimerEvent() {
RuntimeCallStats* stats = isolate_->counters()->runtime_call_stats();
RuntimeCallCounter* counter = stats->current_counter();
......
......@@ -327,6 +327,10 @@ class Logger : public CodeEventListener {
// Logs an IntPtrTEvent regardless of whether FLAG_log is true.
void UncheckedIntPtrTEvent(const char* name, intptr_t value);
// Logs a scripts sources. Keeps track of all logged scripts to ensure that
// each script is logged only once.
bool EnsureLogScriptSource(Script* script);
Isolate* isolate_;
// The sampler used by the profiler and the sliding state window.
......
......@@ -62,10 +62,39 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
overflow-y: scroll;
}
.funktion {
}
.script-size {
display: inline-block;
background-color: #505050;
border-radius: 3px;
padding: 3px;
margin: 2px;
white-space: nowrap;
overflow: hidden;
min-width: 2em;
text-decoration: none;
color: white;
}
.script-size.eval {
background-color: #ee6300fc;
}
.script-size.background {
background-color: #008aff;
}
.script-id {
display: inline;
padding-right: 2px;
margin-right: 2px;
border-right: 1px grey dotted;
}
.script-url {
display: inline;
text-overflow: ellipis;
}
</style>
<script src="./splaytree.js" type="text/javascript"></script>
<script src="./codemap.js" type="text/javascript"></script>
......@@ -156,12 +185,13 @@ function renderParseResults(parseProcessor) {
let result = $('#result');
// clear out all existing result pages;
result.innerHTML = '';
const start = parseProcessor.firstEvent;
const end = parseProcessor.lastEvent;
const start = parseProcessor.firstEventTimestamp;
const end = parseProcessor.lastEventTimestamp;
renderScript(result, parseProcessor.totalScript, start, end);
// Build up the graphs lazily to keep the page responsive.
parseProcessor.scripts.forEach(
script => renderScript(result, script, start, end));
renderScriptSizes(parseProcessor);
// Install an intersection observer to lazily load the graphs when the script
// div becomes visible for the first time.
var io = new IntersectionObserver((entries, observer) => {
......@@ -198,7 +228,31 @@ function renderScript(result, script, start, end) {
summary.appendChild(text(script.summary));
scriptDiv.appendChild(summary);
result.appendChild(scriptDiv);
return scriptDiv;
}
function renderScriptSizes(parseProcessor) {
let scriptsDiv = $('#scripts');
parseProcessor.scripts.forEach(
script => {
let scriptDiv = a('#script'+script.id, '', 'script-size');
let scriptId = div('script-id');
scriptId.innerText = script.id;
scriptDiv.appendChild(scriptId);
let scriptUrl = div('script-url');
if (script.isEval) {
scriptUrl.innerText = "eval";
scriptDiv.classList.add('eval');
} else {
scriptUrl.innerText = script.file.split("/").pop();
}
if (script.isBackgroundCompiled ) {
scriptDiv.classList.add('background');
}
scriptDiv.appendChild(scriptUrl);
scriptDiv.style.width = script.bytesTotal * 0.001;
scriptsDiv.appendChild(scriptDiv);
});
}
const kMaxTime = 120 * kSecondsToMillis;
......@@ -206,13 +260,13 @@ const kMaxTime = 120 * kSecondsToMillis;
const kTimeIncrement = 1;
const kSelectionTimespan = 2;
const series = [
// ['firstParseEvent', 'Any Parse Event'],
['firstParseEvent', 'Any Parse Event'],
['execution', 'First Execution'],
['parse', 'Parsing'],
// ['preparse', 'Preparsing'],
// ['resolution', 'Preparsing with Var. Resolution'],
['preparse', 'Preparsing'],
['resolution', 'Preparsing with Var. Resolution'],
['lazyCompile', 'Lazy Compilation'],
['compile', 'Eager Compilation'],
['execution', 'First Execution'],
];
const metricNames = series.map(each => each[0]);
......@@ -223,18 +277,21 @@ function appendGraph(script, parentNode, start, end) {
console.time(timerLabel);
let data = new google.visualization.DataTable();
data.addColumn('number', 'Time');
data.addColumn('number', 'Duration');
// The series are interleave bytes processed, time spent and thus have two
// different vAxes.
// different vAxes.
let seriesOptions = [];
let colors = ['#4D4D4D', '#5DA5DA', '#FAA43A', '#60BD68', '#F17CB0',
'#B2912F', '#B276B2', '#DECF3F', '#F15854'];
series.forEach(each => {
let description = each[1];
let color = colors.shift();
// Add the bytes column.
data.addColumn('number', description + ' Bytes');
seriesOptions.push({targetAxisIndex: 0});
seriesOptions.push({targetAxisIndex: 0, color: color});
// Add the time column.
data.addColumn('number', description + ' Time');
seriesOptions.push({targetAxisIndex: 1, lineDashStyle: [3, 2]});
data.addColumn('number', description + ' Duration');
seriesOptions.push({targetAxisIndex: 1, color: color, lineDashStyle: [3, 2]});
});
// The first entry contains the total.
seriesOptions[0].type = 'area';
......@@ -257,7 +314,7 @@ function appendGraph(script, parentNode, start, end) {
},
vAxes: {
0: {title: 'Bytes Touched', format: 'short'},
1: {title: 'Time', format: '#,###ms'}
1: {title: 'Duration', format: '#,###ms'}
},
height: 400,
width: 1000,
......@@ -275,6 +332,7 @@ function appendGraph(script, parentNode, start, end) {
google.visualization.events.addListener(chart, 'select',
() => selectGraphPointHandler(chart, data, script, parentNode));
chart.draw(data, options);
// Add event listeners
console.timeEnd(timerLabel);
}
......@@ -311,8 +369,6 @@ function createFunktionList(metric, time, funktions) {
container.appendChild(listNode);
return container;
}
</script>
</head>
......@@ -330,6 +386,10 @@ function createFunktionList(metric, time, funktions) {
</p>
</form>
<h2>Scripts</h2>
<div id="scripts"></div>
<h2>Result</h2>
<div id="result"></div>
</body>
......
......@@ -64,8 +64,47 @@ function timestampMin(list) {
// ===========================================================================
class Script {
const kNoTimeMetrics = {
__proto__: null,
executionDuration: 0,
firstEventTimestamp: 0,
firstParseEventTimestamp: 0,
lastParseEventTimestamp: 0,
lastEventTimestamp: 0
};
class CompilationUnit {
constructor() {
// Lazily computed properties.
this.firstEventTimestamp = -1;
this.firstParseEventTimestamp = -1;
this.lastParseEventTimestamp = -1;
this.lastEventTimestamp = -1;
this.preparseTimestamp = -1;
this.parseTimestamp = -1;
this.parse2Timestamp = -1;
this.resolutionTimestamp = -1;
this.lazyCompileTimestamp = -1;
this.compileTimestamp = -1;
this.executionTimestamp = -1;
this.preparseDuration = -0.0;
this.parseDuration = -0.0;
this.parse2Duration = -0.0;
this.resolutionDuration = -0.0;
this.scopeResolutionDuration = -0.0;
this.lazyCompileDuration = -0.0;
this.compileDuration = -0.0;
this.ownBytes = -1;
}
}
// ===========================================================================
class Script extends CompilationUnit {
constructor(id) {
super();
if (id === void 0 || id <= 0) {
throw new Error(`Invalid id=${id} for script`);
}
......@@ -81,20 +120,11 @@ class Script {
this.metrics = new Map();
this.maxNestingLevel = 0;
this.firstEvent = -1;
this.firstParseEvent = -1;
this.lastParseEvent = -1;
this.executionTimestamp = -1;
this.compileTimestamp = -1;
this.lastEvent = -1;
this.compileTime = -0.0;
this.width = 0;
this.bytesTotal = -1;
this.ownBytes = -1;
this.finalized = false;
this.summary = '';
this.source = '';
}
setFile(name) {
......@@ -107,7 +137,9 @@ class Script {
}
funktionAtPosition(start) {
if (start === 0) throw "position 0 is reserved for the script";
if (!this.isEval && start === 0) {
throw 'position 0 is reserved for the script';
}
if (this.finalized) throw 'Finalized script has no source position!';
return this.funktions[start];
}
......@@ -153,18 +185,42 @@ class Script {
}
parent = fn;
}
this.firstParseEvent = this.firstParseEvent === -1 ?
fn.getFirstParseEvent() :
Math.min(this.firstParseEvent, fn.getFirstParseEvent());
this.lastParseEvent =
Math.max(this.lastParseEvent, fn.getLastParseEvent());
fn.getFirstEvent();
if (Number.isNaN(this.lastEvent)) throw "Invalid lastEvent";
this.lastEvent = Math.max(this.lastEvent, fn.getLastEvent());
if (Number.isNaN(this.lastEvent)) throw "Invalid lastEvent";
this.firstParseEventTimestamp = this.firstParseEventTimestamp === -1 ?
fn.getFirstParseEventTimestamp() :
Math.min(
this.firstParseEventTimestamp, fn.getFirstParseEventTimestamp());
this.lastParseEventTimestamp = Math.max(
this.lastParseEventTimestamp, fn.getLastParseEventTimestamp());
fn.getFirstEventTimestamp();
if (Number.isNaN(this.lastEventTimestamp)) {
throw 'Invalid lastEventTimestamp';
}
this.lastEventTimestamp =
Math.max(this.lastEventTimestamp, fn.getLastEventTimestamp());
if (Number.isNaN(this.lastEventTimestamp)) {
throw 'Invalid lastEventTimestamp';
}
});
this.maxNestingLevel = maxNesting;
this.getFirstEvent();
this.getFirstEventTimestamp();
// Initialize sizes.
if (!this.ownBytes === -1) throw 'Invalid state';
if (this.funktions.length == 0) {
this.bytesTotal = this.ownBytes = 0;
return;
}
let toplevelFunktionBytes = this.funktions.reduce(
(bytes, each) => bytes + (each.isToplevel() ? each.getBytes() : 0), 0);
if (this.isDeserialized || this.isEval || this.isBackgroundCompiled) {
if (this.getBytes() === -1) {
this.bytesTotal = toplevelFunktionBytes;
}
}
this.ownBytes = this.bytesTotal - toplevelFunktionBytes;
if (this.ownBytes < 0) {
console.error(this, 'Own bytes must be positive');
}
}
print() {
......@@ -183,27 +239,16 @@ class Script {
}
getOwnBytes() {
if (this.ownBytes === -1) {
if (this.getBytes() === -1) {
if (this.isDeserialized || this.isEval) {
return this.ownBytes = 0;
}
}
this.ownBytes = this.funktions.reduce(
(bytes, each) => bytes - (each.isToplevel() ? each.getBytes() : 0),
this.getBytes());
if (this.ownBytes < 0) throw "Own bytes must be positive";
}
return this.ownBytes;
}
// Also see Funktion.prototype.getMetricBytes
getMetricBytes(name) {
if (name == 'lazyCompileTimestamp') return this.getOwnBytes();
return this.getBytes();
return this.getOwnBytes();
}
getMetricTime(name) {
getMetricDuration(name) {
return this[name];
}
......@@ -249,52 +294,52 @@ class Script {
info("scripts", this.getScripts());
info("functions", all);
info("toplevel fn", all.filter(each => each.isToplevel()));
info("preparsed", all.filter(each => each.preparseTime > 0));
info('preparsed', all.filter(each => each.preparseDuration > 0));
info("fully parsed", all.filter(each => each.parseTime > 0));
// info("fn parsed", all.filter(each => each.parse2Time > 0));
// info("resolved", all.filter(each => each.resolutionTime > 0));
info('fully parsed', all.filter(each => each.parseDuration > 0));
// info("fn parsed", all.filter(each => each.parse2Duration > 0));
// info("resolved", all.filter(each => each.resolutionDuration > 0));
info("executed", all.filter(each => each.executionTimestamp > 0));
info("forEval", all.filter(each => each.fromEval));
info("lazy compiled", all.filter(each => each.lazyCompileTimestamp > 0));
info("eager compiled", all.filter(each => each.compileTimestamp > 0));
let parsingCost = new ExecutionCost('parse', all,
each => each.parseTime);
let parsingCost =
new ExecutionCost('parse', all, each => each.parseDuration);
parsingCost.setMetrics(this.metrics);
log(parsingCost.toString())
log(parsingCost.toString());
let preParsingCost = new ExecutionCost('preparse', all,
each => each.preparseTime);
let preParsingCost =
new ExecutionCost('preparse', all, each => each.preparseDuration);
preParsingCost.setMetrics(this.metrics);
log(preParsingCost.toString())
log(preParsingCost.toString());
let resolutionCost = new ExecutionCost('resolution', all,
each => each.resolutionTime);
let resolutionCost =
new ExecutionCost('resolution', all, each => each.resolutionDuration);
resolutionCost.setMetrics(this.metrics);
log(resolutionCost.toString())
log(resolutionCost.toString());
let nesting = new NestingDistribution(all);
nesting.setMetrics(this.metrics);
log(nesting.toString())
log(nesting.toString());
if (printSummary) console.log(this.summary);
}
getAccumulatedTimeMetrics(metrics, start, end, delta, incremental = false) {
// Returns an array of the following format:
// [ [start, acc(metric0, start, start), acc(metric1, ...), ...],
// [start+delta, acc(metric0, start, start+delta), ...],
// [ [start, acc(metric0, start, start), acc(metric1, ...), ...],
// [start+delta, acc(metric0, start, start+delta), ...],
// [start+delta*2, acc(metric0, start, start+delta*2), ...],
// ...
// ]
if (end <= start) throw 'Invalid ranges [' + start + ',' + end + ']';
const timespan = end - start;
const kSteps = Math.ceil(timespan / delta);
// To reduce the time spent iterating over the funktions of this script
// we iterate once over all funktions and add the metric changes to each
// timepoint:
// [ [0, 300, ...], [1, 15, ...], [2, 100, ...], [3, 0, ...] ... ]
// [ [0, 300, ...], [1, 15, ...], [2, 100, ...], [3, 0, ...] ... ]
// In a second step we accumulate all values:
// [ [0, 300, ...], [1, 315, ...], [2, 415, ...], [3, 415, ...] ... ]
//
......@@ -304,7 +349,7 @@ class Script {
const metricProperties = ["time"];
metrics.forEach(each => {
metricProperties.push(each + 'Timestamp');
metricProperties.push(each + 'Time');
metricProperties.push(each + 'Duration');
});
// Create a packed {rowTemplate} which is copied later-on.
let indexToTime = (t) => (start + t * delta) / kSecondsToMillis;
......@@ -316,12 +361,14 @@ class Script {
// Create the real metric's property name on the Funktion object.
// Add the increments of each Funktion's metric to the result.
this.forEach(funktionOrScript => {
// Iterate over the Funktion's metric names, position 0 is the time.
// Iterate over the Funktion's metric names, skipping position 0 which
// is the time.
for (let i = 1; i < metricProperties.length; i += 2) {
let property = metricProperties[i];
let timestamp = funktionOrScript[property];
let timestampPropertyName = metricProperties[i];
let timestamp = funktionOrScript[timestampPropertyName];
if (timestamp === void 0) continue;
if (timestamp < 0 || end < timestamp) continue;
if (timestamp < start || end < timestamp) continue;
timestamp -= start;
let index = Math.floor(timestamp / delta);
let row = rows[index];
if (row === null) {
......@@ -331,9 +378,9 @@ class Script {
row[0] = indexToTime(index);
}
// Add the metric value.
row[i] += funktionOrScript.getMetricBytes(property);
let timeMetricName = metricProperties[i + 1];
row[i + 1] += funktionOrScript.getMetricTime(timeMetricName);
row[i] += funktionOrScript.getMetricBytes(timestampPropertyName);
let durationPropertyName = metricProperties[i + 1];
row[i + 1] += funktionOrScript.getMetricDuration(durationPropertyName);
}
});
// Create a packed array again with only the valid entries.
......@@ -386,12 +433,12 @@ class Script {
return result;
}
getFirstEvent() {
if (this.firstEvent === -1) {
getFirstEventTimestamp() {
if (this.firstEventTimestamp === -1) {
// TODO(cbruni): add support for network request timestanp
this.firstEvent = this.firstParseEvent;
this.firstEventTimestamp = this.firstParseEventTimestamp;
}
return this.firstEvent;
return this.firstEventTimestamp;
}
}
......@@ -502,67 +549,41 @@ class ExecutionCost {
}
// ===========================================================================
const kNoTimeMetrics = {
__proto__: null,
executionTime: 0,
firstEventTimestamp: 0,
firstParseEventTimestamp: 0,
lastParseTimestamp: 0,
lastEventTimestamp: 0
};
class Funktion {
class Funktion extends CompilationUnit {
constructor(name, start, end, script) {
super();
if (start < 0) throw "invalid start position: " + start;
if (end <= 0) throw "invalid end position: " + end;
if (end <= start) throw "invalid start end positions";
if (script.isEval) {
if (end < start) throw 'invalid start end positions';
} else {
if (end <= 0) throw 'invalid end position: ' + end;
if (end <= start) throw 'invalid start end positions';
}
this.name = name;
this.start = start;
this.end = end;
this.ownBytes = -1;
this.script = script;
this.parent = null;
this.fromEval = false;
this.nested = [];
this.nestingLevel = 0;
this.preparseTimestamp = -1;
this.parseTimestamp = -1;
this.parse2Timestamp = -1;
this.resolutionTimestamp = -1;
this.lazyCompileTimestamp = -1;
this.compileTimestamp = -1;
this.executionTimestamp = -1;
this.preparseTime = -0.0;
this.parseTime = -0.0;
this.parse2Time = -0.0;
this.resolutionTime = -0.0;
this.scopeResolutionTime = -0.0;
this.lazyCompileTime = -0.0;
this.compileTime = -0.0;
// Lazily computed properties.
this.firstEventTimestamp = -1;
this.firstParseEventTimestamp = -1;
this.lastParseTimestamp = -1;
this.lastEventTimestamp = -1;
if (script) this.script.addFunktion(this);
}
getMetricBytes(name) {
if (name == 'lazyCompileTimestamp') return this.getOwnBytes();
return this.getBytes();
return this.getOwnBytes();
}
getMetricTime(name) {
getMetricDuration(name) {
if (name in kNoTimeMetrics) return 0;
return this[name];
}
getFirstEvent() {
getFirstEventTimestamp() {
if (this.firstEventTimestamp === -1) {
this.firstEventTimestamp = timestampMin(
[this.parseTimestamp, this.preparseTimestamp,
......@@ -575,7 +596,7 @@ class Funktion {
return this.firstEventTimestamp;
}
getFirstParseEvent() {
getFirstParseEventTimestamp() {
if (this.firstParseEventTimestamp === -1) {
this.firstParseEventTimestamp = timestampMin(
[this.parseTimestamp, this.preparseTimestamp,
......@@ -588,23 +609,23 @@ class Funktion {
return this.firstParseEventTimestamp;
}
getLastParseEvent() {
if (this.lastParseTimestamp === -1) {
this.lastParseTimestamp = Math.max(
this.preparseTimestamp + this.preparseTime,
this.parseTimestamp + this.parseTime,
this.resolutionTimestamp + this.resolutionTime);
if (!(this.lastParseTimestamp > 0)) {
this.lastParseTimestamp = 0;
getLastParseEventTimestamp() {
if (this.lastParseEventTimestamp === -1) {
this.lastParseEventTimestamp = Math.max(
this.preparseTimestamp + this.preparseDuration,
this.parseTimestamp + this.parseDuration,
this.resolutionTimestamp + this.resolutionDuration);
if (!(this.lastParseEventTimestamp > 0)) {
this.lastParseEventTimestamp = 0;
}
}
return this.lastParseTimestamp;
return this.lastParseEventTimestamp;
}
getLastEvent() {
getLastEventTimestamp() {
if (this.lastEventTimestamp === -1) {
this.lastEventTimestamp = Math.max(
this.getLastParseEvent(), this.executionTimestamp);
this.lastEventTimestamp =
Math.max(this.getLastParseEventTimestamp(), this.executionTimestamp);
if (!(this.lastEventTimestamp > 0)) {
this.lastEventTimestamp = 0;
}
......@@ -726,7 +747,11 @@ class ParseProcessor extends LogReader {
'script-details': {
parsers: [parseInt, parseString, parseInt, parseInt, parseInt],
processor: this.processScriptDetails
}
},
'script-source': {
parsers: [parseInt, parseString, parseString],
processor: this.processScriptSource
},
};
this.functionEventDispatchTable_ = {
// Avoid accidental leaking of __proto__ properties and force this object
......@@ -753,9 +778,9 @@ class ParseProcessor extends LogReader {
this.nameToFunction = new Map();
this.scripts = [];
this.totalScript = new TotalScript();
this.firstEvent = -1;
this.lastParseEvent = -1;
this.lastEvent = -1;
this.firstEventTimestamp = -1;
this.lastParseEventTimestamp = -1;
this.lastEventTimestamp = -1;
}
print() {
......@@ -800,12 +825,12 @@ class ParseProcessor extends LogReader {
script.calculateMetrics(false)
});
this.firstEvent =
timestampMin(this.scripts.map(each => each.firstEvent));
this.lastParseEvent = this.scripts.reduce(
(max, script) => Math.max(max, script.lastParseEvent), -1);
this.lastEvent = this.scripts.reduce(
(max, script) => Math.max(max, script.lastEvent), -1);
this.firstEventTimestamp =
timestampMin(this.scripts.map(each => each.firstEventTimestamp));
this.lastParseEventTimestamp = this.scripts.reduce(
(max, script) => Math.max(max, script.lastParseEventTimestamp), -1);
this.lastEventTimestamp = this.scripts.reduce(
(max, script) => Math.max(max, script.lastEventTimestamp), -1);
this.scripts.forEach(script => this.totalScript.addAllFunktions(script));
this.totalScript.calculateMetrics(true);
......@@ -819,7 +844,8 @@ class ParseProcessor extends LogReader {
execution: 'First Execution',
};
let metrics = Object.keys(series);
this.totalScript.getAccumulatedTimeMetrics(metrics, 0, this.lastEvent, 10);
this.totalScript.getAccumulatedTimeMetrics(
metrics, 0, this.lastEventTimestamp, 10);
}
processFunctionEvent(
......@@ -892,6 +918,11 @@ class ParseProcessor extends LogReader {
script.setFile(file);
}
processScriptSource(scriptId, url, source) {
let script = this.lookupScript(scriptId);
script.source = source;
}
processEval(
scriptId, startPosition, endPosition, duration, timestamp, functionName) {
let script = this.lookupScript(scriptId);
......@@ -911,14 +942,14 @@ class ParseProcessor extends LogReader {
// parser.
if (funktion.parseTimestamp > 0) return;
funktion.parseTimestamp = startOf(timestamp, duration);
funktion.parseTime = duration;
funktion.parseDuration = duration;
}
processParseFunction(
scriptId, startPosition, endPosition, duration, timestamp, functionName) {
let funktion = this.getOrCreateFunction(...arguments);
funktion.parseTimestamp = startOf(timestamp, duration);
funktion.parseTime = duration;
funktion.parseDuration = duration;
}
processScript(
......@@ -929,7 +960,7 @@ class ParseProcessor extends LogReader {
script.parseTimestamp = ts;
script.firstEventTimestamp = ts;
script.firstParseEventTimestamp = ts;
script.parseTime = duration;
script.parseDuration = duration;
}
processPreparseResolution(
......@@ -939,14 +970,14 @@ class ParseProcessor extends LogReader {
// parser.
if (funktion.resolutionTimestamp > 0) return;
funktion.resolutionTimestamp = startOf(timestamp, duration);
funktion.resolutionTime = duration;
funktion.resolutionDuration = duration;
}
processPreparseNoResolution(
scriptId, startPosition, endPosition, duration, timestamp, functionName) {
let funktion = this.getOrCreateFunction(...arguments);
funktion.preparseTimestamp = startOf(timestamp, duration);
funktion.preparseTime = duration;
funktion.preparseDuration = duration;
}
processFirstExecution(
......@@ -971,7 +1002,7 @@ class ParseProcessor extends LogReader {
scriptId, startPosition, endPosition, duration, timestamp, functionName) {
let funktion = this.getOrCreateFunction(...arguments);
funktion.lazyCompileTimestamp = startOf(timestamp, duration);
funktion.lazyCompileTime = duration;
funktion.lazyCompileDuration = duration;
}
processCompile(
......@@ -979,7 +1010,7 @@ class ParseProcessor extends LogReader {
let script = this.lookupScript(scriptId);
if (startPosition === 0) {
script.compileTimestamp = startOf(timestamp, duration);
script.compileTime = duration;
script.compileDuration = duration;
script.bytesTotal = endPosition;
} else {
let funktion = script.funktionAtPosition(startPosition);
......@@ -988,7 +1019,7 @@ class ParseProcessor extends LogReader {
console.log("processCompile funktion not found", ...arguments);
}
funktion.compileTimestamp = startOf(timestamp, duration);
funktion.compileTime = duration;
funktion.compileDuration = duration;
}
}
......
......@@ -120,9 +120,9 @@ function TickProcessor(
parsers: [parseInt, parseInt, parseInt, parseInt, parseString,
parseString, parseString],
processor: this.processCodeSourceInfo },
'script': {
'script-source': {
parsers: [parseInt, parseString, parseString],
processor: this.processCodeScript },
processor: this.processScriptSource },
'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove },
'active-runtime-timer': {
......@@ -333,7 +333,7 @@ TickProcessor.prototype.processCodeSourceInfo = function(
endPos, sourcePositions, inliningPositions, inlinedFunctions);
};
TickProcessor.prototype.processCodeScript = function(script, url, source) {
TickProcessor.prototype.processScriptSource = function(script, url, source) {
this.profile_.addScriptSource(script, url, source);
};
......
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