Fix rolling averages in diagnostic status.

* updates sampler to return `num`s
* migrates status get_handler to one shared handler for diagnostics

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1490623002 .
This commit is contained in:
pq
2015-11-30 21:24:10 -08:00
parent 0e4ac0b7e4
commit c84ea322ff
2 changed files with 14 additions and 5 deletions
@@ -138,7 +138,7 @@ class Sampler {
}
/// Get the average for the context associated with the given [folder].
int getAverage(Folder folder) {
num getAverage(Folder folder) {
resetTimerCountdown();
return averages[folder].value;
}
@@ -183,11 +183,23 @@ class GetHandler {
*/
final Map<String, String> _overlayContents = <String, String>{};
/**
* Handler for diagnostics requests.
*/
DiagnosticDomainHandler _diagnosticHandler;
/**
* Initialize a newly created handler for GET requests.
*/
GetHandler(this._server, this._printBuffer);
DiagnosticDomainHandler get diagnosticHandler {
if (_diagnosticHandler == null) {
_diagnosticHandler = new DiagnosticDomainHandler(_server.analysisServer);
}
return _diagnosticHandler;
}
/**
* Return the active [CompletionDomainHandler]
* or `null` if either analysis server is not running
@@ -1484,14 +1496,11 @@ class GetHandler {
* Write the status of the diagnostic domain to the given [buffer].
*/
void _writeDiagnosticStatus(StringBuffer buffer) {
DiagnosticDomainHandler handler =
new DiagnosticDomainHandler(_server.analysisServer);
var request = new DiagnosticGetDiagnosticsParams().toRequest('0');
var stopwatch = new Stopwatch();
stopwatch.start();
var response = handler.handleRequest(request);
var response = diagnosticHandler.handleRequest(request);
stopwatch.stop();
int elapsedMs = stopwatch.elapsedMilliseconds;