Remove unused global counters and timers.

Change-Id: I5a4dfbde154711a98b4752e4f5c6168ddd341853
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index e6f16c0..b7fddeb 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -43,11 +43,6 @@
 import 'package:path/path.dart' as package_path;
 import 'package:pub_semver/pub_semver.dart';
 
-var counterFileStateRefresh = 0;
-var counterUnlinkedBytes = 0;
-var counterUnlinkedLinkedBytes = 0;
-var timerFileStateRefresh = Stopwatch();
-
 /// A library from [SummaryDataStore].
 class ExternalLibrary {
   final Uri uri;
@@ -382,13 +377,6 @@
   ///
   /// Return how the file changed since the last refresh.
   FileStateRefreshResult refresh() {
-    counterFileStateRefresh++;
-
-    var timerWasRunning = timerFileStateRefresh.isRunning;
-    if (!timerWasRunning) {
-      timerFileStateRefresh.start();
-    }
-
     _invalidateCurrentUnresolvedData();
 
     final rawFileState = _fsState._fileContentCache.get(path);
@@ -468,10 +456,6 @@
       files.add(this);
     }
 
-    if (!timerWasRunning) {
-      timerFileStateRefresh.stop();
-    }
-
     // Return how the file changed.
     if (apiSignatureChanged) {
       return FileStateRefreshResult.apiChanged;
@@ -528,8 +512,6 @@
       );
       var bytes = driverUnlinkedUnit.toBytes();
       _fsState._byteStore.put(_unlinkedKey!, bytes);
-      counterUnlinkedBytes += bytes.length;
-      counterUnlinkedLinkedBytes += bytes.length;
       return driverUnlinkedUnit;
     });
   }
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index f1ad356..b4ff5c0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -52,13 +52,6 @@
 import 'package:analyzer/src/util/performance/operation_performance.dart';
 import 'package:analyzer/src/util/uri.dart';
 
-var timerLibraryAnalyzer = Stopwatch();
-var timerLibraryAnalyzerConst = Stopwatch();
-var timerLibraryAnalyzerFreshUnit = Stopwatch();
-var timerLibraryAnalyzerResolve = Stopwatch();
-var timerLibraryAnalyzerSplicer = Stopwatch();
-var timerLibraryAnalyzerVerify = Stopwatch();
-
 class AnalysisForCompletionResult {
   final CompilationUnit parsedUnit;
   final List<AstNode> resolvedNodes;
@@ -112,7 +105,6 @@
       errors = _filterIgnoredErrors(file, errors);
       results.add(UnitAnalysisResult(file, unit, errors));
     });
-    timerLibraryAnalyzer.stop();
     return results;
   }
 
@@ -258,7 +250,6 @@
   /// Compute diagnostics in [units], including errors and warnings, hints,
   /// lints, and a few other cases.
   void _computeDiagnostics(Map<FileState, CompilationUnitImpl> units) {
-    timerLibraryAnalyzerVerify.start();
     units.forEach((file, unit) {
       _computeVerifyErrors(file, unit);
     });
@@ -313,7 +304,6 @@
         _analysisOptions.unignorableNames,
       ).reportErrors();
     }
-    timerLibraryAnalyzerVerify.stop();
   }
 
   void _computeHints(
@@ -575,15 +565,12 @@
 
   /// Parse and resolve all files in [_library].
   Map<FileState, CompilationUnitImpl> _parseAndResolve() {
-    timerLibraryAnalyzer.start();
     var units = <FileState, CompilationUnitImpl>{};
 
     // Parse all files.
-    timerLibraryAnalyzerFreshUnit.start();
     for (FileState file in _library.libraryFiles) {
       units[file] = _parse(file);
     }
-    timerLibraryAnalyzerFreshUnit.stop();
 
     // Resolve URIs in directives to corresponding sources.
     FeatureSet featureSet = units[_library]!.featureSet;
@@ -592,18 +579,13 @@
       _resolveUriBasedDirectives(file, unit);
     });
 
-    timerLibraryAnalyzerResolve.start();
     _resolveDirectives(units);
 
     units.forEach((file, unit) {
       _resolveFile(file, unit);
     });
-    timerLibraryAnalyzerResolve.stop();
-
-    timerLibraryAnalyzerConst.start();
 
     _computeConstants(units.values);
-    timerLibraryAnalyzerConst.stop();
 
     return units;
   }
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 3d44aa2..311c3b0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -28,13 +28,6 @@
 import 'package:analyzer/src/summary2/reference.dart';
 import 'package:path/src/context.dart';
 
-var counterLinkedLibraries = 0;
-var counterLoadedLibraries = 0;
-var timerBundleToBytes = Stopwatch(); // TODO(scheglov) use
-var timerInputLibraries = Stopwatch();
-var timerLinking = Stopwatch();
-var timerLoad = Stopwatch();
-
 /// Context information necessary to analyze one or more libraries within an
 /// [AnalysisDriver].
 ///
@@ -113,7 +106,6 @@
 
   /// Load data required to access elements of the given [targetLibrary].
   Future<void> load(FileState targetLibrary) async {
-    timerLoad.start();
     var librariesTotal = 0;
     var librariesLoaded = 0;
     var librariesLinked = 0;
@@ -170,7 +162,6 @@
           cycle.libraries.map((e) => e.path).toSet(),
         );
 
-        timerInputLibraries.start();
         inputsTimer.start();
         var inputLibraries = <LinkInputLibrary>[];
         for (var libraryFile in cycle.libraries) {
@@ -209,16 +200,12 @@
           );
         }
         inputsTimer.stop();
-        timerInputLibraries.stop();
 
         LinkResult linkResult;
         try {
-          timerLinking.start();
           linkResult = await link(elementFactory, inputLibraries,
               macroExecutor: macroExecutor);
           librariesLinked += cycle.libraries.length;
-          counterLinkedLibraries += inputLibraries.length;
-          timerLinking.stop();
         } catch (exception, stackTrace) {
           _throwLibraryCycleLinkException(cycle, exception, stackTrace);
         }
@@ -226,7 +213,6 @@
         resolutionBytes = linkResult.resolutionBytes;
         byteStore.put(resolutionKey, resolutionBytes);
         bytesPut += resolutionBytes.length;
-        counterUnlinkedLinkedBytes += resolutionBytes.length;
 
         librariesLinkedTimer.stop();
       } else {
@@ -290,8 +276,6 @@
     // already include the [targetLibrary]. When this happens, [loadBundle]
     // exists without doing any work. But the type provider must be created.
     _createElementFactoryTypeProvider();
-
-    timerLoad.stop();
   }
 
   /// Ensure that type provider is created.
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 819b202..b68a8cf 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -25,8 +25,6 @@
 import 'package:analyzer/src/summary2/types_builder.dart';
 import 'package:analyzer/src/summary2/variance_builder.dart';
 
-var timerLinkingLinkingBundle = Stopwatch();
-
 /// Note that AST units and tokens of [inputLibraries] will be damaged.
 Future<LinkResult> link(
   LinkedElementFactory elementFactory,
@@ -85,10 +83,7 @@
     }
 
     await _buildOutlines();
-
-    timerLinkingLinkingBundle.start();
     _writeLibraries();
-    timerLinkingLinkingBundle.stop();
   }
 
   void _buildEnumChildren() {