[tfa] Make kPrintStats runtime configurable
Currently we have to ask users to run TFA from source
(which requires a lot of dances with figuring out
command line and checking out Dart SDK).
However statistics printing does not impose any runtime
overhead (as opposed for example to kPrintTimings
which tracks timings) so it can be runtime configurable.
Inspired by https://github.com/flutter/flutter/issues/136529
TEST=tested manually
Change-Id: Ie496d6babb1e8cbbbb9a665b14656ea334a2eeed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331881
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
diff --git a/pkg/vm/lib/transformations/type_flow/utils.dart b/pkg/vm/lib/transformations/type_flow/utils.dart
index 8b786c2..2f04c48 100644
--- a/pkg/vm/lib/transformations/type_flow/utils.dart
+++ b/pkg/vm/lib/transformations/type_flow/utils.dart
@@ -6,6 +6,8 @@
/// analysis.
library vm.transformations.type_flow.utils;
+import 'dart:io';
+
import 'package:collection/collection.dart' show IterableExtension;
import 'package:kernel/ast.dart';
import 'package:kernel/src/printer.dart';
@@ -21,8 +23,8 @@
const bool kPrintTimings =
const bool.fromEnvironment('global.type.flow.print.timings');
-const bool kPrintStats =
- const bool.fromEnvironment('global.type.flow.print.stats');
+bool printStats = bool.fromEnvironment('global.type.flow.print.stats') ||
+ Platform.environment['DART_TFA_PRINT_STATS'] == '1';
const bool kRemoveAsserts =
const bool.fromEnvironment('global.type.flow.remove.asserts');
@@ -93,7 +95,7 @@
}
statPrint(Object message) {
- if (kPrintStats) {
+ if (printStats) {
_logger.log(message);
}
}