Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: pkg/analysis_server/benchmark/integration/input_converter.dart

Issue 1249793007: performance measurement mods: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/benchmark/integration/input_converter.dart
diff --git a/pkg/analysis_server/benchmark/integration/input_converter.dart b/pkg/analysis_server/benchmark/integration/input_converter.dart
index ef90131cb56835fecfeb5ca9caaa692a6bc0ae53..3d9fd5a392afaa8e5318b9183eafeabf0c661a32 100644
--- a/pkg/analysis_server/benchmark/integration/input_converter.dart
+++ b/pkg/analysis_server/benchmark/integration/input_converter.dart
@@ -62,7 +62,7 @@ abstract class CommonInputConverter extends Converter<String, Operation> {
* from location where instrumentation or log file was generated
* to the target location of the source using during performance measurement.
*/
- final Map<String, String> srcPathMap;
+ final PathMap srcPathMap;
/**
* The root directory for all source being modified
@@ -70,13 +70,7 @@ abstract class CommonInputConverter extends Converter<String, Operation> {
*/
final String tmpSrcDirPath;
- /**
- * The diagnostic port for Analysis Server or `null` if none.
- */
- final int diagnosticPort;
-
- CommonInputConverter(this.tmpSrcDirPath, this.srcPathMap,
- {this.diagnosticPort});
+ CommonInputConverter(this.tmpSrcDirPath, this.srcPathMap);
/**
* Return an operation for the notification or `null` if none.
@@ -95,7 +89,7 @@ abstract class CommonInputConverter extends Converter<String, Operation> {
}
if (event == SERVER_CONNECTED) {
// {"event":"server.connected","params":{"version":"1.7.0"}}
- return new StartServerOperation(diagnosticPort: diagnosticPort);
+ return new StartServerOperation();
}
if (eventsSeen.add(event)) {
logger.log(Level.INFO, 'Ignored notification: $event\n $json');
@@ -182,6 +176,14 @@ abstract class CommonInputConverter extends Converter<String, Operation> {
this, requestMap.remove(json['id']), translateSrcPaths(json));
}
+ void logOverlayContent() {
+ logger.log(Level.WARNING, '${overlays.length} overlays');
+ List<String> allPaths = overlays.keys.toList()..sort();
+ for (String filePath in allPaths) {
+ logger.log(Level.WARNING, 'overlay $filePath\n${overlays[filePath]}');
+ }
+ }
+
/**
* Process an error response from the server by either
* completing the associated completer in the [responseCompleters]
@@ -242,13 +244,7 @@ abstract class CommonInputConverter extends Converter<String, Operation> {
*/
translateSrcPaths(json) {
if (json is String) {
- String result = json;
- srcPathMap.forEach((String oldPrefix, String newPrefix) {
- if (json.startsWith(oldPrefix)) {
- result = '$newPrefix${json.substring(oldPrefix.length)}';
- }
- });
- return result;
+ return srcPathMap.translate(json);
}
if (json is List) {
List result = [];
@@ -281,7 +277,7 @@ class InputConverter extends Converter<String, Operation> {
* from location where instrumentation or log file was generated
* to the target location of the source using during performance measurement.
*/
- final Map<String, String> srcPathMap;
+ final PathMap srcPathMap;
/**
* The root directory for all source being modified
@@ -290,11 +286,6 @@ class InputConverter extends Converter<String, Operation> {
final String tmpSrcDirPath;
/**
- * The diagnostic port for Analysis Server or `null` if none.
- */
- final int diagnosticPort;
-
- /**
* The number of lines read before the underlying converter was determined
* or the end of file was reached.
*/
@@ -312,7 +303,7 @@ class InputConverter extends Converter<String, Operation> {
*/
bool active = true;
- InputConverter(this.tmpSrcDirPath, this.srcPathMap, {this.diagnosticPort});
+ InputConverter(this.tmpSrcDirPath, this.srcPathMap);
@override
Operation convert(String line) {
@@ -331,11 +322,9 @@ class InputConverter extends Converter<String, Operation> {
throw 'Failed to determine input file format';
}
if (InstrumentationInputConverter.isFormat(line)) {
- converter = new InstrumentationInputConverter(tmpSrcDirPath, srcPathMap,
- diagnosticPort: diagnosticPort);
+ converter = new InstrumentationInputConverter(tmpSrcDirPath, srcPathMap);
} else if (LogFileInputConverter.isFormat(line)) {
- converter = new LogFileInputConverter(tmpSrcDirPath, srcPathMap,
- diagnosticPort: diagnosticPort);
+ converter = new LogFileInputConverter(tmpSrcDirPath, srcPathMap);
}
if (converter != null) {
return converter.convert(line);
@@ -350,6 +339,43 @@ class InputConverter extends Converter<String, Operation> {
}
}
+/**
+ * A container of [PathMapEntry]s used to translate a source path in the log
+ * before it is sent to the analysis server.
+ */
+class PathMap {
+ final List<PathMapEntry> entries = [];
+
+ void add(String oldSrcPrefix, String newSrcPrefix) {
+ entries.add(new PathMapEntry(oldSrcPrefix, newSrcPrefix));
+ }
+
+ String translate(String original) {
+ String result = original;
+ for (PathMapEntry entry in entries) {
+ result = entry.translate(result);
+ }
+ return result;
+ }
+}
+
+/**
+ * An entry in [PathMap] used to translate a source path in the log
+ * before it is sent to the analysis server.
+ */
+class PathMapEntry {
+ final String oldSrcPrefix;
+ final String newSrcPrefix;
+
+ PathMapEntry(this.oldSrcPrefix, this.newSrcPrefix);
+
+ String translate(String original) {
+ return original.startsWith(oldSrcPrefix)
+ ? '$newSrcPrefix${original.substring(oldSrcPrefix.length)}'
+ : original;
+ }
+}
+
class _InputSink extends ChunkedConversionSink<String> {
final Converter<String, Operation> converter;
final outSink;

Powered by Google App Engine
This is Rietveld 408576698