separateIc,
TickProcessor.CALL_GRAPH_SIZE,
ignoreUnknown,
- stateFilter);
+ stateFilter,
+ undefined,
+ "0",
+ "auto,auto");
var pm = new PrintMonitor(testsPath + refOutput);
tp.processLogFileInTest(testsPath + logInput);
tp.printStatistics();
exit 1
fi
-if [ -n "$DISTORTION" ]; then
- distortion=$DISTORTION
-else
+if [[ "$@" != *--distortion* ]]; then
# Try to find out how much the instrumentation overhead is.
calibration_log=calibration.log
calibration_script="for (var i = 0; i < 1000000; i++) print();"
rm $calibration_log
# Overhead in picoseconds.
- distortion=`echo "1000*(($t_1_end - $t_1_start) - ($t_2_end - $t_2_start)) \
- / ($n_1 - $n_2)" | bc`
+ options=--distortion=
+ options+=`echo "1000*(($t_1_end - $t_1_start) - ($t_2_end - $t_2_start)) \
+ / ($n_1 - $n_2)" | bc`
+ echo $options
fi
-if [ -n "$PLOT_RANGE" ]; then
- plot_range=$PLOT_RANGE
-else
- plot_range=auto,auto
-fi
-
-echo "DISTORTION=$distortion"
-echo "PLOT_RANGE=$plot_range"
-
echo -e "plot-range,$plot_range\ndistortion,$distortion" | cat - $log_file |
- $d8_exec $tools_path/csvparser.js \
- $tools_path/splaytree.js $tools_path/codemap.js \
- $tools_path/logreader.js $tools_path/plot-timer-events.js \
+ $d8_exec $tools_path/csvparser.js $tools_path/splaytree.js \
+ $tools_path/codemap.js $tools_path/profile.js $tools_path/profile_view.js \
+ $tools_path/logreader.js $tools_path/tickprocessor.js \
+ $tools_path/plot-timer-events.js -- $options $@ | less \
2>/dev/null | gnuplot > timer-events.png
}
-function ProcessDistortion(distortion_in_picoseconds) {
- distortion_per_entry = distortion_in_picoseconds / 1000000;
-}
-
-
-function ProcessPlotRange(start, end) {
- xrange_start_override = start;
- xrange_end_override = end;
-}
-
-
function FindPlotRange() {
var start_found = (xrange_start_override || xrange_start_override == 0);
var end_found = (xrange_end_override || xrange_end_override == 0);
}
+function ParseArguments(args) {
+ var processor = new ArgumentsProcessor(args);
+ do {
+ if (!processor.parse()) break;
+ var result = processor.result();
+ var distortion = parseInt(result.distortion);
+ if (isNaN(distortion)) break;
+ // Convert picoseconds to milliseconds.
+ distortion_per_entry = distortion / 1000000;
+ var rangelimits = result.range.split(",");
+ var range_start = parseInt(rangelimits[0]);
+ var range_end = parseInt(rangelimits[1]);
+ xrange_start_override = isNaN(range_start) ? undefined : range_start;
+ xrange_end_override = isNaN(range_end) ? undefined : range_end;
+ return;
+ } while (false);
+ processor.printUsageAndExit();
+}
+
+
function CollectData() {
// Collect data from log.
var logreader = new LogReader(
processor: ProcessCodeDeleteEvent },
'tick': { parsers: [parseInt, parseInt, parseTimeStamp,
null, null, parseInt, 'var-args'],
- processor: ProcessTickEvent },
- 'distortion': { parsers: [parseInt],
- processor: ProcessDistortion },
- 'plot-range': { parsers: [parseInt, parseInt],
- processor: ProcessPlotRange },
+ processor: ProcessTickEvent }
});
var line;
function GnuplotOutput() {
- FindPlotRange();
-
print("set terminal pngcairo size " + kResX + "," + kResY +
" enhanced font 'Helvetica,10'");
print("set yrange [0:" + (num_timer_event + 1) + "]");
}
+ParseArguments(arguments);
CollectData();
+FindPlotRange();
GnuplotOutput();
params.callGraphSize,
params.ignoreUnknown,
params.stateFilter,
- snapshotLogProcessor);
+ snapshotLogProcessor,
+ params.distortion,
+ params.range);
tickProcessor.processLogFile(params.logFileName);
tickProcessor.printStatistics();
callGraphSize,
ignoreUnknown,
stateFilter,
- snapshotLogProcessor) {
+ snapshotLogProcessor,
+ distortion,
+ range) {
LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt],
processor: this.processSharedLibrary },
processor: this.processHeapSampleBegin },
'heap-sample-end': { parsers: [null, null],
processor: this.processHeapSampleEnd },
+ 'timer-event-start' : { parsers: [null, null, null],
+ processor: this.advanceDistortion },
+ 'timer-event-end' : { parsers: [null, null, null],
+ processor: this.advanceDistortion },
// Ignored events.
'profiler': null,
'function-creation': null,
var ticks = this.ticks_ =
{ total: 0, unaccounted: 0, excluded: 0, gc: 0 };
+ distortion = parseInt(distortion);
+ // Convert picoseconds to nanoseconds.
+ this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000);
+ this.distortion = 0;
+ var rangelimits = range.split(",");
+ var range_start = parseInt(rangelimits[0]);
+ var range_end = parseInt(rangelimits[1]);
+ // Convert milliseconds to nanoseconds.
+ this.range_start = isNaN(range_start) ? -Infinity : (range_start * 1000);
+ this.range_end = isNaN(range_end) ? Infinity : (range_end * 1000)
+
V8Profile.prototype.handleUnknownCode = function(
operation, addr, opt_stackPos) {
var op = Profile.Operation;
tos_or_external_callback,
vmState,
stack) {
+ this.distortion += this.distortion_per_entry;
+ ns_since_start -= this.distortion;
+ if (ns_since_start < this.range_start || ns_since_start > this.range_end) {
+ return;
+ }
this.ticks_.total++;
if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
if (!this.includeTick(vmState)) {
};
+TickProcessor.prototype.advanceDistortion = function() {
+ this.distortion += this.distortion_per_entry;
+}
+
+
TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
if (space != 'Heap') return;
this.currentProducerProfile_ = new CallTree();
'--target': ['targetRootFS', '',
'Specify the target root directory for cross environment'],
'--snapshot-log': ['snapshotLogFileName', 'snapshot.log',
- 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)']
+ 'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'],
+ '--range': ['range', 'auto,auto',
+ 'Specify the range limit as [start],[end]'],
+ '--distortion': ['distortion', 0,
+ 'Specify the logging overhead in picoseconds']
};
this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];
ignoreUnknown: false,
separateIc: false,
targetRootFS: '',
- nm: 'nm'
+ nm: 'nm',
+ range: 'auto,auto',
+ distortion: 0
};