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

Unified Diff: lib/info.dart

Issue 1372333002: Add measurements and send-metrics to dart2js's info. (Closed) Base URL: git@github.com:dart-lang/dart2js_info.git@master
Patch Set: Created 5 years, 2 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: lib/info.dart
diff --git a/lib/info.dart b/lib/info.dart
index 40cefe2f15c2c9145c4de88994957293afa10f9d..0c07c1bb35034c86a2564647921858f31bb98585 100644
--- a/lib/info.dart
+++ b/lib/info.dart
@@ -5,8 +5,12 @@
/// Data produced by dart2js when run with the `--dump-info` flag.
library dart2js_info.info;
+import 'src/measurements.dart';
+export 'src/measurements.dart';
+
/// Common interface to many pieces of information generated by the dart2js
-/// compiler.
+/// compiler that are directly associated with an element (compilation unit,
+/// library, class, function, or field).
abstract class Info {
/// An identifier for the kind of information.
InfoKind get kind;
@@ -369,12 +373,34 @@ class _ParseHelper {
..code = json['code']
..sideEffects = json['sideEffects']
..modifiers = parseModifiers(json['modifiers'])
- ..closures = json['children'].map(parseId).toList();
+ ..closures = json['children'].map(parseId).toList()
+ ..measurements = parseMeasurements(json['measurements']);
}
ParameterInfo parseParameter(Map json) =>
new ParameterInfo(json['name'], json['type'], json['declaredType']);
+ Measurements parseMeasurements(Map json) {
+ if (json == null) return null;
+ var uri = json['sourceFile'];
+ var res = new Measurements(uri == null ? null : Uri.parse(uri));
+ for (var key in json.keys) {
+ var value = json[key];
+ if (value == null) continue;
+ if (key == 'entries') {
+ value.forEach((metricName, entries) {
+ var metric = Metric.fromJson(metricName);
+ for (var i = 0; i < entries.length; i += 2) {
+ res.record(metric, entries[i], entries[i + 1]);
+ }
+ });
+ } else {
+ res.counters[Metric.fromJson(key)] = value;
+ }
+ }
+ return res;
+ }
+
FunctionModifiers parseModifiers(Map<String, bool> json) {
return new FunctionModifiers(
isStatic: json['static'] == true,
@@ -422,6 +448,10 @@ class LibraryInfo extends BasicInfo {
/// Typedefs defined within the library.
final List<TypedefInfo> typedefs = <TypedefInfo>[];
+ // TODO(sigmund): add here a list of parts. That can help us improve how we
+ // encode source-span information in metrics (rather than include the uri on
+ // each function, include an index into this list).
+
static int _id = 0;
/// Whether there is any information recorded for this library.
@@ -618,6 +648,9 @@ class FunctionInfo extends BasicInfo with CodeInfo {
/// The actual generated code.
String code;
+ /// Measurements collected for this function.
+ Measurements measurements;
+
FunctionInfo(
{String name,
String coverageId,
@@ -632,7 +665,8 @@ class FunctionInfo extends BasicInfo with CodeInfo {
this.parameters,
this.sideEffects,
this.inlinedCount,
- this.code})
+ this.code,
+ this.measurements})
: super(InfoKind.function, _ids++, name, outputUnit, size, coverageId);
FunctionInfo._(String serializedId) : super._fromId(serializedId);
@@ -648,6 +682,7 @@ class FunctionInfo extends BasicInfo with CodeInfo {
'inlinedCount': inlinedCount,
'code': code,
'type': type,
+ 'measurements': measurements?.toJson(),
// Note: version 3.2 of dump-info serializes `uses` in a section called
// `holding` at the top-level.
});
« no previous file with comments | « bin/inference/server.dart ('k') | lib/src/measurements.dart » ('j') | lib/src/table.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698