| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library server.performance; | 5 library server.performance; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 const TMP_SRC_DIR_OPTION = 'tmpSrcDir'; | 68 const TMP_SRC_DIR_OPTION = 'tmpSrcDir'; |
| 69 const VERBOSE_CMDLINE_OPTION = 'verbose'; | 69 const VERBOSE_CMDLINE_OPTION = 'verbose'; |
| 70 const VERY_VERBOSE_CMDLINE_OPTION = 'vv'; | 70 const VERY_VERBOSE_CMDLINE_OPTION = 'vv'; |
| 71 | 71 |
| 72 ArgParser _argParser; | 72 ArgParser _argParser; |
| 73 | 73 |
| 74 ArgParser get argParser { | 74 ArgParser get argParser { |
| 75 _argParser = new ArgParser(); | 75 _argParser = new ArgParser(); |
| 76 | 76 |
| 77 _argParser.addOption(INPUT_CMDLINE_OPTION, abbr: 'i', help: '<filePath>\n' | 77 _argParser.addOption(INPUT_CMDLINE_OPTION, |
| 78 'The input file specifying how this client should interact with the server
.\n' | 78 abbr: 'i', |
| 79 'If the input file name is "stdin", then the instructions are read from st
andard input.'); | 79 help: '<filePath>\n' |
| 80 'The input file specifying how this client should interact with the se
rver.\n' |
| 81 'If the input file name is "stdin", then the instructions are read fro
m standard input.'); |
| 80 _argParser.addOption(MAP_OPTION, | 82 _argParser.addOption(MAP_OPTION, |
| 81 abbr: 'm', | 83 abbr: 'm', |
| 82 allowMultiple: true, | 84 allowMultiple: true, |
| 83 splitCommas: false, | 85 splitCommas: false, |
| 84 help: '<oldSrcPath>,<newSrcPath>\n' | 86 help: '<oldSrcPath>,<newSrcPath>\n' |
| 85 'This option defines a mapping from the original source directory <old
SrcPath>\n' | 87 'This option defines a mapping from the original source directory <old
SrcPath>\n' |
| 86 'when the instrumentation or log file was generated\n' | 88 'when the instrumentation or log file was generated\n' |
| 87 'to the target source directory <newSrcPath> used during performance t
esting.\n' | 89 'to the target source directory <newSrcPath> used during performance t
esting.\n' |
| 88 'Multiple mappings can be specified.\n' | 90 'Multiple mappings can be specified.\n' |
| 89 'WARNING: The contents of the target directory will be modified'); | 91 'WARNING: The contents of the target directory will be modified'); |
| 90 _argParser.addOption(TMP_SRC_DIR_OPTION, abbr: 't', help: '<dirPath>\n' | 92 _argParser.addOption(TMP_SRC_DIR_OPTION, |
| 91 'The temporary directory containing source used during performance measure
ment.\n' | 93 abbr: 't', |
| 92 'WARNING: The contents of the target directory will be modified'); | 94 help: '<dirPath>\n' |
| 95 'The temporary directory containing source used during performance mea
surement.\n' |
| 96 'WARNING: The contents of the target directory will be modified'); |
| 93 _argParser.addFlag(NEW_TASK_MODEL_OPTION, | 97 _argParser.addFlag(NEW_TASK_MODEL_OPTION, |
| 94 help: "enable the use of the new task model", | 98 help: "enable the use of the new task model", |
| 95 defaultsTo: false, | 99 defaultsTo: false, |
| 96 negatable: false); | 100 negatable: false); |
| 97 _argParser.addOption(DIAGNOSTIC_PORT_OPTION, | 101 _argParser.addOption(DIAGNOSTIC_PORT_OPTION, |
| 98 abbr: 'd', | 102 abbr: 'd', |
| 99 help: 'localhost port on which server will provide diagnostic web pages'); | 103 help: 'localhost port on which server will provide diagnostic web pages'); |
| 100 _argParser.addFlag(VERBOSE_CMDLINE_OPTION, | 104 _argParser.addFlag(VERBOSE_CMDLINE_OPTION, |
| 101 abbr: 'v', help: 'Verbose logging', negatable: false); | 105 abbr: 'v', help: 'Verbose logging', negatable: false); |
| 102 _argParser.addFlag(VERY_VERBOSE_CMDLINE_OPTION, | 106 _argParser.addFlag(VERY_VERBOSE_CMDLINE_OPTION, |
| 103 help: 'Extra verbose logging', negatable: false); | 107 help: 'Extra verbose logging', negatable: false); |
| 104 _argParser.addFlag(HELP_CMDLINE_OPTION, | 108 _argParser.addFlag(HELP_CMDLINE_OPTION, |
| 105 abbr: 'h', help: 'Print this help information', negatable: false); | 109 abbr: 'h', help: 'Print this help information', negatable: false); |
| 106 return _argParser; | 110 return _argParser; |
| 107 } | 111 } |
| 108 | 112 |
| 109 /** | 113 /** |
| 110 * Open and return the input stream specifying how this client | 114 * Open and return the input stream specifying how this client |
| 111 * should interact with the analysis server. | 115 * should interact with the analysis server. |
| 112 */ | 116 */ |
| 113 Stream<Operation> openInput(PerfArgs args) { | 117 Stream<Operation> openInput(PerfArgs args) { |
| 114 var logger = new Logger('openInput'); | 118 var logger = new Logger('openInput'); |
| 115 Stream<List<int>> inputRaw; | 119 Stream<List<int>> inputRaw; |
| 116 if (args.inputPath == 'stdin') { | 120 if (args.inputPath == 'stdin') { |
| 117 inputRaw = stdin; | 121 inputRaw = stdin; |
| 118 } else { | 122 } else { |
| 119 inputRaw = new File(args.inputPath).openRead(); | 123 inputRaw = new File(args.inputPath).openRead(); |
| 120 } | 124 } |
| 121 for (PathMapEntry entry in args.srcPathMap.entries) { | 125 for (PathMapEntry entry in args.srcPathMap.entries) { |
| 122 logger.log(Level.INFO, 'mapping source path\n' | 126 logger.log( |
| 127 Level.INFO, |
| 128 'mapping source path\n' |
| 123 ' from ${entry.oldSrcPrefix}\n to ${entry.newSrcPrefix}'); | 129 ' from ${entry.oldSrcPrefix}\n to ${entry.newSrcPrefix}'); |
| 124 } | 130 } |
| 125 logger.log(Level.INFO, 'tmpSrcDir: ${args.tmpSrcDirPath}'); | 131 logger.log(Level.INFO, 'tmpSrcDir: ${args.tmpSrcDirPath}'); |
| 126 return inputRaw | 132 return inputRaw |
| 127 .transform(SYSTEM_ENCODING.decoder) | 133 .transform(SYSTEM_ENCODING.decoder) |
| 128 .transform(new LineSplitter()) | 134 .transform(new LineSplitter()) |
| 129 .transform(new InputConverter(args.tmpSrcDirPath, args.srcPathMap)); | 135 .transform(new InputConverter(args.tmpSrcDirPath, args.srcPathMap)); |
| 130 } | 136 } |
| 131 | 137 |
| 132 /** | 138 /** |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 return '$dirPath${path.separator}'; | 223 return '$dirPath${path.separator}'; |
| 218 } | 224 } |
| 219 } | 225 } |
| 220 return dirPath; | 226 return dirPath; |
| 221 } | 227 } |
| 222 | 228 |
| 223 /** | 229 /** |
| 224 * The performance measurement arguments specified on the command line. | 230 * The performance measurement arguments specified on the command line. |
| 225 */ | 231 */ |
| 226 class PerfArgs { | 232 class PerfArgs { |
| 227 | |
| 228 /** | 233 /** |
| 229 * The file path of the instrumentation or log file | 234 * The file path of the instrumentation or log file |
| 230 * used to drive performance measurement, | 235 * used to drive performance measurement, |
| 231 * or 'stdin' if this information should be read from standard input. | 236 * or 'stdin' if this information should be read from standard input. |
| 232 */ | 237 */ |
| 233 String inputPath; | 238 String inputPath; |
| 234 | 239 |
| 235 /** | 240 /** |
| 236 * A mapping from the original source directory | 241 * A mapping from the original source directory |
| 237 * when the instrumentation or log file was generated | 242 * when the instrumentation or log file was generated |
| 238 * to the target source directory used during performance testing. | 243 * to the target source directory used during performance testing. |
| 239 */ | 244 */ |
| 240 final PathMap srcPathMap = new PathMap(); | 245 final PathMap srcPathMap = new PathMap(); |
| 241 | 246 |
| 242 /** | 247 /** |
| 243 * The temporary directory containing source used during performance measureme
nt. | 248 * The temporary directory containing source used during performance measureme
nt. |
| 244 */ | 249 */ |
| 245 String tmpSrcDirPath; | 250 String tmpSrcDirPath; |
| 246 | 251 |
| 247 /** | 252 /** |
| 248 * The diagnostic port for Analysis Server or `null` if none. | 253 * The diagnostic port for Analysis Server or `null` if none. |
| 249 */ | 254 */ |
| 250 int diagnosticPort; | 255 int diagnosticPort; |
| 251 | 256 |
| 252 /** | 257 /** |
| 253 * `true` if the server should run using the new task model. | 258 * `true` if the server should run using the new task model. |
| 254 */ | 259 */ |
| 255 bool newTaskModel; | 260 bool newTaskModel; |
| 256 } | 261 } |
| OLD | NEW |