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

[tools] Move common arguments processing into separate file

Change-Id: Ia7b30b3f9d19ac1a6da978a0bd884e8f6f38841b
Reviewed-on: https://chromium-review.googlesource.com/730570
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48850}
parent 46588ce1
...@@ -427,6 +427,7 @@ action("resources") { ...@@ -427,6 +427,7 @@ action("resources") {
"../../tools/consarray.js", "../../tools/consarray.js",
"../../tools/profile.js", "../../tools/profile.js",
"../../tools/profile_view.js", "../../tools/profile_view.js",
"../../tools/arguments.js",
"../../tools/logreader.js", "../../tools/logreader.js",
"log-eq-of-logging-and-traversal.js", "log-eq-of-logging-and-traversal.js",
] ]
......
...@@ -447,6 +447,7 @@ ...@@ -447,6 +447,7 @@
'../../tools/consarray.js', '../../tools/consarray.js',
'../../tools/profile.js', '../../tools/profile.js',
'../../tools/profile_view.js', '../../tools/profile_view.js',
'../../tools/arguments.js',
'../../tools/logreader.js', '../../tools/logreader.js',
'log-eq-of-logging-and-traversal.js', 'log-eq-of-logging-and-traversal.js',
], ],
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
'../../tools/consarray.js', '../../tools/consarray.js',
'../../tools/csvparser.js', '../../tools/csvparser.js',
'../../tools/logreader.js', '../../tools/logreader.js',
'../../tools/arguments.js',
'../../tools/profile.js', '../../tools/profile.js',
'../../tools/profile_view.js', '../../tools/profile_view.js',
'../../tools/profviz/composer.js', '../../tools/profviz/composer.js',
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Load implementations from <project root>/tools. // Load implementations from <project root>/tools.
// Files: tools/splaytree.js tools/codemap.js tools/csvparser.js // Files: tools/splaytree.js tools/codemap.js tools/csvparser.js
// Files: tools/consarray.js tools/profile.js tools/profile_view.js // Files: tools/consarray.js tools/profile.js tools/profile_view.js
// Files: tools/logreader.js tools/tickprocessor.js // Files: tools/logreader.js tools/arguments.js tools/tickprocessor.js
// Files: tools/dumpcpp.js // Files: tools/dumpcpp.js
// Env: TEST_FILE_NAME // Env: TEST_FILE_NAME
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
// Load implementations from <project root>/tools. // Load implementations from <project root>/tools.
// Files: tools/csvparser.js tools/splaytree.js tools/codemap.js // Files: tools/csvparser.js tools/splaytree.js tools/codemap.js
// Files: tools/consarray.js tools/profile.js tools/profile_view.js // Files: tools/consarray.js tools/profile.js tools/profile_view.js
// Files: tools/logreader.js tools/tickprocessor.js // Files: tools/logreader.js tools/arguments.js tools/tickprocessor.js
// Files: tools/profviz/composer.js // Files: tools/profviz/composer.js
// Env: TEST_FILE_NAME // Env: TEST_FILE_NAME
......
...@@ -28,14 +28,14 @@ ...@@ -28,14 +28,14 @@
// Load implementations from <project root>/tools. // Load implementations from <project root>/tools.
// Files: tools/splaytree.js tools/codemap.js tools/csvparser.js // Files: tools/splaytree.js tools/codemap.js tools/csvparser.js
// Files: tools/consarray.js tools/profile.js tools/profile_view.js // Files: tools/consarray.js tools/profile.js tools/profile_view.js
// Files: tools/logreader.js tools/tickprocessor.js // Files: tools/logreader.js tools/arguments.js tools/tickprocessor.js
// Env: TEST_FILE_NAME // Env: TEST_FILE_NAME
(function testArgumentsProcessor() { (function testArgumentsProcessor() {
var p_default = new ArgumentsProcessor([]); var p_default = new ArgumentsProcessor([]);
assertTrue(p_default.parse()); assertTrue(p_default.parse());
assertEquals(ArgumentsProcessor.DEFAULTS, p_default.result()); assertEquals(p_default.getDefaultResults(), p_default.result());
var p_logFile = new ArgumentsProcessor(['logfile.log']); var p_logFile = new ArgumentsProcessor(['logfile.log']);
assertTrue(p_logFile.parse()); assertTrue(p_logFile.parse());
......
...@@ -100,6 +100,7 @@ sync_file tools/profile.js ...@@ -100,6 +100,7 @@ sync_file tools/profile.js
sync_file tools/splaytree.js sync_file tools/splaytree.js
sync_file tools/profile_view.js sync_file tools/profile_view.js
sync_file tools/logreader.js sync_file tools/logreader.js
sync_file tools/arguments.js
sync_file tools/tickprocessor.js sync_file tools/tickprocessor.js
echo "" echo ""
sync_dir tools/profviz sync_dir tools/profviz
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
class BaseArgumentsProcessor {
constructor(args) {
this.args_ = args;
this.result_ = this.getDefaultResults();
console.assert(this.result_ !== undefined)
console.assert(this.result_.logFileName !== undefined);
this.argsDispatch_ = this.getArgsDispatch();
console.assert(this.argsDispatch_ !== undefined);
}
getDefaultResults() {
throw "Implement in getDefaultResults in subclass";
}
getArgsDispatch() {
throw "Implement getArgsDispatch in subclass";
}
result() { return this.result_ }
printUsageAndExit() {
print('Cmdline args: [options] [log-file-name]\n' +
'Default log file name is "' +
this.result_.logFileName + '".\n');
print('Options:');
for (var arg in this.argsDispatch_) {
var synonyms = [arg];
var dispatch = this.argsDispatch_[arg];
for (var synArg in this.argsDispatch_) {
if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
synonyms.push(synArg);
delete this.argsDispatch_[synArg];
}
}
print(' ' + synonyms.join(', ').padEnd(20) + " " + dispatch[2]);
}
quit(2);
}
parse() {
while (this.args_.length) {
var arg = this.args_.shift();
if (arg.charAt(0) != '-') {
this.result_.logFileName = arg;
continue;
}
var userValue = null;
var eqPos = arg.indexOf('=');
if (eqPos != -1) {
userValue = arg.substr(eqPos + 1);
arg = arg.substr(0, eqPos);
}
if (arg in this.argsDispatch_) {
var dispatch = this.argsDispatch_[arg];
var property = dispatch[0];
var defaultValue = dispatch[1];
if (typeof defaultValue == "function") {
userValue = defaultValue(userValue);
} else if (userValue == null) {
userValue = defaultValue;
}
this.result_[property] = userValue;
} else {
return false;
}
}
return true;
}
}
function parseBool(str) {
if (str == "true" || str == "1") return true;
return false;
}
...@@ -17,8 +17,8 @@ def is_file_executable(fPath): ...@@ -17,8 +17,8 @@ def is_file_executable(fPath):
if __name__ == '__main__': if __name__ == '__main__':
JS_FILES = ['splaytree.js', 'codemap.js', 'csvparser.js', 'consarray.js', JS_FILES = ['splaytree.js', 'codemap.js', 'csvparser.js', 'consarray.js',
'profile.js', 'logreader.js', 'tickprocessor.js', 'SourceMap.js', 'profile.js', 'logreader.js', 'arguments.js', 'tickprocessor.js',
'dumpcpp.js', 'dumpcpp-driver.js'] 'SourceMap.js', 'dumpcpp.js', 'dumpcpp-driver.js']
tools_path = os.path.dirname(os.path.realpath(__file__)) tools_path = os.path.dirname(os.path.realpath(__file__))
on_windows = platform.system() == 'Windows' on_windows = platform.system() == 'Windows'
JS_FILES = [os.path.join(tools_path, f) for f in JS_FILES] JS_FILES = [os.path.join(tools_path, f) for f in JS_FILES]
......
...@@ -53,6 +53,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -53,6 +53,7 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
<script src="./profile.js" type="text/javascript"></script> <script src="./profile.js" type="text/javascript"></script>
<script src="./profile_view.js" type="text/javascript"></script> <script src="./profile_view.js" type="text/javascript"></script>
<script src="./logreader.js" type="text/javascript"></script> <script src="./logreader.js" type="text/javascript"></script>
<script src="./arguments.js" type="text/javascript"></script>
<script src="./ic-processor.js" type="text/javascript"></script> <script src="./ic-processor.js" type="text/javascript"></script>
<script src="./SourceMap.js" type="text/javascript"></script> <script src="./SourceMap.js" type="text/javascript"></script>
......
...@@ -36,6 +36,6 @@ fi ...@@ -36,6 +36,6 @@ fi
cat $log_file | $d8_exec $tools_path/splaytree.js $tools_path/codemap.js \ cat $log_file | $d8_exec $tools_path/splaytree.js $tools_path/codemap.js \
$tools_path/csvparser.js $tools_path/consarray.js \ $tools_path/csvparser.js $tools_path/consarray.js \
$tools_path/profile.js $tools_path/profile_view.js \ $tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/ic-processor.js \ $tools_path/logreader.js $tools_path/arguments.js \
$tools_path/SourceMap.js \ $tools_path/ic-processor.js $tools_path/SourceMap.js \
$tools_path/ic-processor-driver.js -- $@ 2>/dev/null $tools_path/ic-processor-driver.js -- $@ 2>/dev/null
...@@ -159,91 +159,20 @@ IcProcessor.prototype.processPropertyIC = function ( ...@@ -159,91 +159,20 @@ IcProcessor.prototype.processPropertyIC = function (
" (map 0x" + map.toString(16) + ")"); " (map 0x" + map.toString(16) + ")");
} }
function padLeft(s, len) {
s = s.toString();
if (s.length < len) {
var padLength = len - s.length;
if (!(padLength in padLeft)) {
padLeft[padLength] = new Array(padLength + 1).join(' ');
}
s = padLeft[padLength] + s;
}
return s;
};
function ArgumentsProcessor(args) {
this.args_ = args;
this.result_ = ArgumentsProcessor.DEFAULTS;
this.argsDispatch_ = {
'--range': ['range', 'auto,auto',
'Specify the range limit as [start],[end]'],
'--source-map': ['sourceMap', null,
'Specify the source map that should be used for output']
};
};
class ArgumentsProcessor extends BaseArgumentsProcessor {
ArgumentsProcessor.DEFAULTS = { getArgsDispatch() {
logFileName: 'v8.log', return {
range: 'auto,auto', '--range': ['range', 'auto,auto',
}; 'Specify the range limit as [start],[end]'],
'--source-map': ['sourceMap', null,
'Specify the source map that should be used for output']
ArgumentsProcessor.prototype.parse = function() { };
while (this.args_.length) {
var arg = this.args_.shift();
if (arg.charAt(0) != '-') {
this.result_.logFileName = arg;
continue;
}
var userValue = null;
var eqPos = arg.indexOf('=');
if (eqPos != -1) {
userValue = arg.substr(eqPos + 1);
arg = arg.substr(0, eqPos);
}
if (arg in this.argsDispatch_) {
var dispatch = this.argsDispatch_[arg];
this.result_[dispatch[0]] = userValue == null ? dispatch[1] : userValue;
} else {
return false;
}
} }
return true; getDefaultResults() {
}; return {
logFileName: 'v8.log',
range: 'auto,auto',
ArgumentsProcessor.prototype.result = function() { };
return this.result_;
};
ArgumentsProcessor.prototype.printUsageAndExit = function() {
function padRight(s, len) {
s = s.toString();
if (s.length < len) {
s = s + (new Array(len - s.length + 1).join(' '));
}
return s;
}
print('Cmdline args: [options] [log-file-name]\n' +
'Default log file name is "' +
ArgumentsProcessor.DEFAULTS.logFileName + '".\n');
print('Options:');
for (var arg in this.argsDispatch_) {
var synonyms = [arg];
var dispatch = this.argsDispatch_[arg];
for (var synArg in this.argsDispatch_) {
if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
synonyms.push(synArg);
delete this.argsDispatch_[synArg];
}
}
print(' ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]);
} }
quit(2); }
};
...@@ -37,6 +37,6 @@ cat $log_file | $d8_exec --enable-os-system \ ...@@ -37,6 +37,6 @@ cat $log_file | $d8_exec --enable-os-system \
$tools_path/splaytree.js $tools_path/codemap.js \ $tools_path/splaytree.js $tools_path/codemap.js \
$tools_path/csvparser.js $tools_path/consarray.js \ $tools_path/csvparser.js $tools_path/consarray.js \
$tools_path/profile.js $tools_path/profile_view.js \ $tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \ $tools_path/logreader.js $tools_path/arguments.js \
$tools_path/SourceMap.js \ $tools_path/tickprocessor.js $tools_path/SourceMap.js \
$tools_path/tickprocessor-driver.js -- $@ 2>/dev/null $tools_path/tickprocessor-driver.js -- $@ 2>/dev/null
...@@ -78,8 +78,9 @@ fi ...@@ -78,8 +78,9 @@ fi
cat $log_file | cat $log_file |
$d8_exec $tools_path/csvparser.js $tools_path/splaytree.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/codemap.js $tools_path/profile.js $tools_path/profile_view.js \
$tools_path/logreader.js $tools_path/tickprocessor.js \ $tools_path/logreader.js $tools_path/arguments.js \
$tools_path/profviz/composer.js $tools_path/profviz/stdio.js \ $tools_path/tickprocessor.js$tools_path/profviz/composer.js \
$tools_path/profviz/stdio.js \
-- $@ $options 2>/dev/null > timer-events.plot -- $@ $options 2>/dev/null > timer-events.plot
success=$? success=$?
......
...@@ -33,6 +33,7 @@ var worker_scripts = [ ...@@ -33,6 +33,7 @@ var worker_scripts = [
"../profile.js", "../profile.js",
"../profile_view.js", "../profile_view.js",
"../logreader.js", "../logreader.js",
"../arguments.js",
"../tickprocessor.js", "../tickprocessor.js",
"composer.js", "composer.js",
"gnuplot-4.6.3-emscripten.js" "gnuplot-4.6.3-emscripten.js"
......
...@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> ...@@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -->
<script src="profile.js"></script> <script src="profile.js"></script>
<script src="profile_view.js"></script> <script src="profile_view.js"></script>
<script src="logreader.js"></script> <script src="logreader.js"></script>
<script src="arguments.js"></script>
<script src="tickprocessor.js"></script> <script src="tickprocessor.js"></script>
<script type="text/javascript"> <script type="text/javascript">
...@@ -80,7 +81,7 @@ function print(arg) { ...@@ -80,7 +81,7 @@ function print(arg) {
} }
function start_process() { function start_process() {
ArgumentsProcessor.DEFAULTS = { let DEFAULTS = {
logFileName: 'v8.log', logFileName: 'v8.log',
platform: 'unix', platform: 'unix',
stateFilter: null, stateFilter: null,
...@@ -98,13 +99,10 @@ function start_process() { ...@@ -98,13 +99,10 @@ function start_process() {
}; };
var tickProcessor = new TickProcessor( var tickProcessor = new TickProcessor(
new (entriesProviders[ArgumentsProcessor.DEFAULTS.platform])( new (entriesProviders[DEFAULTS.platform])(
ArgumentsProcessor.DEFAULTS.nm, DEFAULTS.nm, DEFAULTS.targetRootFS),
ArgumentsProcessor.DEFAULTS.targetRootFS), DEFAULTS.separateIc, DEFAULTS.callGraphSize,
ArgumentsProcessor.DEFAULTS.separateIc, DEFAULTS.ignoreUnknown, DEFAULTS.stateFilter);
ArgumentsProcessor.DEFAULTS.callGraphSize,
ArgumentsProcessor.DEFAULTS.ignoreUnknown,
ArgumentsProcessor.DEFAULTS.stateFilter);
tickProcessor.processLogChunk(v8log_content); tickProcessor.processLogChunk(v8log_content);
tickProcessor.printStatistics(); tickProcessor.printStatistics();
......
...@@ -842,159 +842,91 @@ WindowsCppEntriesProvider.prototype.unmangleName = function(name) { ...@@ -842,159 +842,91 @@ WindowsCppEntriesProvider.prototype.unmangleName = function(name) {
}; };
function ArgumentsProcessor(args) { class ArgumentsProcessor extends BaseArgumentsProcessor {
this.args_ = args; getArgsDispatch() {
this.result_ = ArgumentsProcessor.DEFAULTS; let dispatch = {
function parseBool(str) { '-j': ['stateFilter', TickProcessor.VmStates.JS,
if (str == "true" || str == "1") return true; 'Show only ticks from JS VM state'],
return false; '-g': ['stateFilter', TickProcessor.VmStates.GC,
} 'Show only ticks from GC VM state'],
'-p': ['stateFilter', TickProcessor.VmStates.PARSER,
this.argsDispatch_ = { 'Show only ticks from PARSER VM state'],
'-j': ['stateFilter', TickProcessor.VmStates.JS, '-b': ['stateFilter', TickProcessor.VmStates.BYTECODE_COMPILER,
'Show only ticks from JS VM state'], 'Show only ticks from BYTECODE_COMPILER VM state'],
'-g': ['stateFilter', TickProcessor.VmStates.GC, '-c': ['stateFilter', TickProcessor.VmStates.COMPILER,
'Show only ticks from GC VM state'], 'Show only ticks from COMPILER VM state'],
'-p': ['stateFilter', TickProcessor.VmStates.PARSER, '-o': ['stateFilter', TickProcessor.VmStates.OTHER,
'Show only ticks from PARSER VM state'], 'Show only ticks from OTHER VM state'],
'-b': ['stateFilter', TickProcessor.VmStates.BYTECODE_COMPILER, '-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL,
'Show only ticks from BYTECODE_COMPILER VM state'], 'Show only ticks from EXTERNAL VM state'],
'-c': ['stateFilter', TickProcessor.VmStates.COMPILER, '--filter-runtime-timer': ['runtimeTimerFilter', null,
'Show only ticks from COMPILER VM state'], 'Show only ticks matching the given runtime timer scope'],
'-o': ['stateFilter', TickProcessor.VmStates.OTHER, '--call-graph-size': ['callGraphSize', TickProcessor.CALL_GRAPH_SIZE,
'Show only ticks from OTHER VM state'], 'Set the call graph size'],
'-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL, '--ignore-unknown': ['ignoreUnknown', true,
'Show only ticks from EXTERNAL VM state'], 'Exclude ticks of unknown code entries from processing'],
'--filter-runtime-timer': ['runtimeTimerFilter', null, '--separate-ic': ['separateIc', parseBool,
'Show only ticks matching the given runtime timer scope'], 'Separate IC entries'],
'--call-graph-size': ['callGraphSize', TickProcessor.CALL_GRAPH_SIZE, '--separate-bytecodes': ['separateBytecodes', parseBool,
'Set the call graph size'], 'Separate Bytecode entries'],
'--ignore-unknown': ['ignoreUnknown', true, '--separate-builtins': ['separateBuiltins', parseBool,
'Exclude ticks of unknown code entries from processing'], 'Separate Builtin entries'],
'--separate-ic': ['separateIc', parseBool, '--separate-stubs': ['separateStubs', parseBool,
'Separate IC entries'], 'Separate Stub entries'],
'--separate-bytecodes': ['separateBytecodes', parseBool, '--unix': ['platform', 'unix',
'Separate Bytecode entries'], 'Specify that we are running on *nix platform'],
'--separate-builtins': ['separateBuiltins', parseBool, '--windows': ['platform', 'windows',
'Separate Builtin entries'], 'Specify that we are running on Windows platform'],
'--separate-stubs': ['separateStubs', parseBool, '--mac': ['platform', 'mac',
'Separate Stub entries'], 'Specify that we are running on Mac OS X platform'],
'--unix': ['platform', 'unix', '--nm': ['nm', 'nm',
'Specify that we are running on *nix platform'], 'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'],
'--windows': ['platform', 'windows', '--target': ['targetRootFS', '',
'Specify that we are running on Windows platform'], 'Specify the target root directory for cross environment'],
'--mac': ['platform', 'mac', '--range': ['range', 'auto,auto',
'Specify that we are running on Mac OS X platform'], 'Specify the range limit as [start],[end]'],
'--nm': ['nm', 'nm', '--distortion': ['distortion', 0,
'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'], 'Specify the logging overhead in picoseconds'],
'--target': ['targetRootFS', '', '--source-map': ['sourceMap', null,
'Specify the target root directory for cross environment'], 'Specify the source map that should be used for output'],
'--range': ['range', 'auto,auto', '--timed-range': ['timedRange', true,
'Specify the range limit as [start],[end]'], 'Ignore ticks before first and after last Date.now() call'],
'--distortion': ['distortion', 0, '--pairwise-timed-range': ['pairwiseTimedRange', true,
'Specify the logging overhead in picoseconds'], 'Ignore ticks outside pairs of Date.now() calls'],
'--source-map': ['sourceMap', null, '--only-summary': ['onlySummary', true,
'Specify the source map that should be used for output'], 'Print only tick summary, exclude other information'],
'--timed-range': ['timedRange', true, '--preprocess': ['preprocessJson', true,
'Ignore ticks before first and after last Date.now() call'], 'Preprocess for consumption with web interface']
'--pairwise-timed-range': ['pairwiseTimedRange', true, };
'Ignore ticks outside pairs of Date.now() calls'], dispatch['--js'] = dispatch['-j'];
'--only-summary': ['onlySummary', true, dispatch['--gc'] = dispatch['-g'];
'Print only tick summary, exclude other information'], dispatch['--compiler'] = dispatch['-c'];
'--preprocess': ['preprocessJson', true, dispatch['--other'] = dispatch['-o'];
'Preprocess for consumption with web interface'] dispatch['--external'] = dispatch['-e'];
}; dispatch['--ptr'] = dispatch['--pairwise-timed-range'];
this.argsDispatch_['--js'] = this.argsDispatch_['-j']; return dispatch;
this.argsDispatch_['--gc'] = this.argsDispatch_['-g']; }
this.argsDispatch_['--compiler'] = this.argsDispatch_['-c'];
this.argsDispatch_['--other'] = this.argsDispatch_['-o']; getDefaultResults() {
this.argsDispatch_['--external'] = this.argsDispatch_['-e']; return {
this.argsDispatch_['--ptr'] = this.argsDispatch_['--pairwise-timed-range']; logFileName: 'v8.log',
}; platform: 'unix',
stateFilter: null,
callGraphSize: 5,
ArgumentsProcessor.DEFAULTS = { ignoreUnknown: false,
logFileName: 'v8.log', separateIc: true,
platform: 'unix', separateBytecodes: false,
stateFilter: null, separateBuiltins: true,
callGraphSize: 5, separateStubs: true,
ignoreUnknown: false, preprocessJson: null,
separateIc: true, targetRootFS: '',
separateBytecodes: false, nm: 'nm',
separateBuiltins: true, range: 'auto,auto',
separateStubs: true, distortion: 0,
preprocessJson: null, timedRange: false,
targetRootFS: '', pairwiseTimedRange: false,
nm: 'nm', onlySummary: false,
range: 'auto,auto', runtimeTimerFilter: null,
distortion: 0, };
timedRange: false,
pairwiseTimedRange: false,
onlySummary: false,
runtimeTimerFilter: null,
};
ArgumentsProcessor.prototype.parse = function() {
while (this.args_.length) {
var arg = this.args_.shift();
if (arg.charAt(0) != '-') {
this.result_.logFileName = arg;
continue;
}
var userValue = null;
var eqPos = arg.indexOf('=');
if (eqPos != -1) {
userValue = arg.substr(eqPos + 1);
arg = arg.substr(0, eqPos);
}
if (arg in this.argsDispatch_) {
var dispatch = this.argsDispatch_[arg];
var property = dispatch[0];
var defaultValue = dispatch[1];
if (typeof defaultValue == "function") {
userValue = defaultValue(userValue);
} else if (userValue == null) {
userValue = defaultValue;
}
this.result_[property] = userValue;
} else {
return false;
}
}
return true;
};
ArgumentsProcessor.prototype.result = function() {
return this.result_;
};
ArgumentsProcessor.prototype.printUsageAndExit = function() {
function padRight(s, len) {
s = s.toString();
if (s.length < len) {
s = s + (new Array(len - s.length + 1).join(' '));
}
return s;
}
print('Cmdline args: [options] [log-file-name]\n' +
'Default log file name is "' +
ArgumentsProcessor.DEFAULTS.logFileName + '".\n');
print('Options:');
for (var arg in this.argsDispatch_) {
var synonyms = [arg];
var dispatch = this.argsDispatch_[arg];
for (var synArg in this.argsDispatch_) {
if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
synonyms.push(synArg);
delete this.argsDispatch_[synArg];
}
}
print(' ' + padRight(synonyms.join(', '), 20) + " " + dispatch[2]);
} }
quit(2); }
};
...@@ -27,4 +27,4 @@ IF NOT %arg8:~0,2% == 8 (IF NOT %arg8:~0,2% == 8- SET log_file=%8) ...@@ -27,4 +27,4 @@ IF NOT %arg8:~0,2% == 8 (IF NOT %arg8:~0,2% == 8- SET log_file=%8)
SET arg9=9%9 SET arg9=9%9
IF NOT %arg9:~0,2% == 9 (IF NOT %arg9:~0,2% == 9- SET log_file=%9) IF NOT %arg9:~0,2% == 9 (IF NOT %arg9:~0,2% == 9- SET log_file=%9)
type %log_file% | %D8_PATH%\d8 %tools_dir%splaytree.js %tools_dir%codemap.js %tools_dir%csvparser.js %tools_dir%consarray.js %tools_dir%profile.js %tools_dir%profile_view.js %tools_dir%logreader.js %tools_dir%SourceMap.js %tools_dir%tickprocessor.js %tools_dir%tickprocessor-driver.js -- --windows %* type %log_file% | %D8_PATH%\d8 %tools_dir%splaytree.js %tools_dir%codemap.js %tools_dir%csvparser.js %tools_dir%consarray.js %tools_dir%profile.js %tools_dir%profile_view.js %tools_dir%logreader.js %tools_dir%SourceMap.js %tools_dir%arguments.js %tools_dir%tickprocessor.js %tools_dir%tickprocessor-driver.js -- --windows %*
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