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

Unified Diff: pkg/analysis_server/lib/src/domain_diagnostic.dart

Issue 1489583003: Diagnostic status reporting (#24932). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/status/get_handler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/domain_diagnostic.dart
diff --git a/pkg/analysis_server/lib/src/domain_diagnostic.dart b/pkg/analysis_server/lib/src/domain_diagnostic.dart
index e6a2ac03f0c003be9c9141350c9fa72cff10850f..22e34880dc0c92803c6228741e6d54a44e4c80a6 100644
--- a/pkg/analysis_server/lib/src/domain_diagnostic.dart
+++ b/pkg/analysis_server/lib/src/domain_diagnostic.dart
@@ -10,6 +10,7 @@ import 'dart:core' hide Resource;
import 'package:analysis_server/plugin/protocol/protocol.dart';
import 'package:analysis_server/src/analysis_server.dart';
+import 'package:analysis_server/src/utilities/average.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/context/cache.dart';
import 'package:analyzer/src/context/context.dart';
@@ -128,7 +129,7 @@ class Sampler {
/// Map of contexts (tracked as folders to avoid leaks) to averages.
/// TOOD(pq): consider adding GC to remove mappings for deleted folders
- Map<Folder, _Average> averages = new HashMap<Folder, _Average>();
+ Map<Folder, Average> averages = new HashMap<Folder, Average>();
final AnalysisServer server;
Sampler(this.server) {
@@ -174,9 +175,9 @@ class Sampler {
try {
server.folderMap.forEach((Folder folder, AnalysisContext context) {
if (context is AnalysisContextImpl) {
- _Average average = averages[folder];
+ Average average = averages[folder];
if (average == null) {
- average = new _Average();
+ average = new Average();
averages[folder] = average;
}
average.addSample(_workItemCount(context));
@@ -187,25 +188,3 @@ class Sampler {
}
}
}
-
-/// Simple rolling average sample counter.
-class _Average {
- num _val;
-
- final int sampleCount;
- _Average([this.sampleCount = 20]);
-
- num get value => _val ?? 0;
-
- void addSample(num sample) {
- if (_val == null) {
- _val = sample;
- } else {
- _val =
- _val * ((sampleCount - 1) / sampleCount) + sample * (1 / sampleCount);
- }
- }
-
- @override
- String toString() => 'average: ${value}';
-}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/status/get_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698