Commit 20e83e3e authored by Devon Carew's avatar Devon Carew Committed by GitHub

change the reload success message to include both the elapsed time and the library count (#9328)

parent 89a7fdfc
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert' show ASCII, LineSplitter; import 'dart:convert' show ASCII, LineSplitter;
import 'package:intl/intl.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'io.dart'; import 'io.dart';
import 'platform.dart'; import 'platform.dart';
import 'utils.dart';
final AnsiTerminal terminal = new AnsiTerminal(); final AnsiTerminal terminal = new AnsiTerminal();
...@@ -320,8 +320,6 @@ class _AnsiStatus extends Status { ...@@ -320,8 +320,6 @@ class _AnsiStatus extends Status {
} }
static final List<String> _progress = <String>['-', r'\', '|', r'/', '-', r'\', '|', '/']; static final List<String> _progress = <String>['-', r'\', '|', r'/', '-', r'\', '|', '/'];
static final NumberFormat secondsFormat = new NumberFormat('0.0');
static final NumberFormat millisecondsFormat = new NumberFormat.decimalPattern();
final String message; final String message;
final bool expectSlowOperation; final bool expectSlowOperation;
...@@ -345,10 +343,9 @@ class _AnsiStatus extends Status { ...@@ -345,10 +343,9 @@ class _AnsiStatus extends Status {
live = false; live = false;
if (expectSlowOperation) { if (expectSlowOperation) {
final double seconds = stopwatch.elapsedMilliseconds / Duration.MILLISECONDS_PER_SECOND; print('\b\b\b\b\b${getElapsedAsSeconds(stopwatch.elapsed).padLeft(5)}');
print('\b\b\b\b\b${secondsFormat.format(seconds).padLeft(4)}s');
} else { } else {
print('\b\b\b\b\b${millisecondsFormat.format(stopwatch.elapsedMilliseconds).padLeft(3)}ms'); print('\b\b\b\b\b${getElapsedAsMilliseconds(stopwatch.elapsed).padLeft(5)}');
} }
timer.cancel(); timer.cancel();
......
...@@ -7,6 +7,7 @@ import 'dart:convert'; ...@@ -7,6 +7,7 @@ import 'dart:convert';
import 'dart:math' show Random; import 'dart:math' show Random;
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:intl/intl.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'platform.dart'; import 'platform.dart';
...@@ -82,7 +83,17 @@ String getSizeAsMB(int bytesLength) { ...@@ -82,7 +83,17 @@ String getSizeAsMB(int bytesLength) {
return '${(bytesLength / (1024 * 1024)).toStringAsFixed(1)}MB'; return '${(bytesLength / (1024 * 1024)).toStringAsFixed(1)}MB';
} }
String getElapsedAsMilliseconds(Duration duration) => '${duration.inMilliseconds} ms'; final NumberFormat kSecondsFormat = new NumberFormat('0.0');
final NumberFormat kMillisecondsFormat = new NumberFormat.decimalPattern();
String getElapsedAsSeconds(Duration duration) {
final double seconds = duration.inMilliseconds / Duration.MILLISECONDS_PER_SECOND;
return '${kSecondsFormat.format(seconds)}s';
}
String getElapsedAsMilliseconds(Duration duration) {
return '${kMillisecondsFormat.format(duration.inMilliseconds)}ms';
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an /// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path. /// absolute path.
......
...@@ -361,24 +361,28 @@ class HotRunner extends ResidentRunner { ...@@ -361,24 +361,28 @@ class HotRunner extends ResidentRunner {
if (fullRestart) { if (fullRestart) {
final Status status = logger.startProgress('Performing full restart...', progressId: 'hot.restart'); final Status status = logger.startProgress('Performing full restart...', progressId: 'hot.restart');
try { try {
final Stopwatch timer = new Stopwatch()..start();
await _restartFromSources(); await _restartFromSources();
status.stop(); timer.stop();
printStatus('Restart complete.'); status.cancel();
printStatus('Restarted app in ${getElapsedAsSeconds(timer.elapsed)}.');
return OperationResult.ok; return OperationResult.ok;
} catch (error) { } catch (error) {
status.stop(); status.cancel();
rethrow; rethrow;
} }
} else { } else {
final Status status = logger.startProgress('Performing hot reload...', progressId: 'hot.reload'); final Status status = logger.startProgress('Performing hot reload...', progressId: 'hot.reload');
try { try {
final Stopwatch timer = new Stopwatch()..start();
final OperationResult result = await _reloadSources(pause: pauseAfterRestart); final OperationResult result = await _reloadSources(pause: pauseAfterRestart);
status.stop(); timer.stop();
status.cancel();
if (result.isOk) if (result.isOk)
printStatus("${result.message}."); printStatus("Reloaded ${result.message} in ${getElapsedAsMilliseconds(timer.elapsed)}.");
return result; return result;
} catch (error) { } catch (error) {
status.stop(); status.cancel();
rethrow; rethrow;
} }
} }
...@@ -434,7 +438,8 @@ class HotRunner extends ResidentRunner { ...@@ -434,7 +438,8 @@ class HotRunner extends ResidentRunner {
flutterUsage.sendEvent('hot', 'reload'); flutterUsage.sendEvent('hot', 'reload');
final int loadedLibraryCount = reloadReport['details']['loadedLibraryCount']; final int loadedLibraryCount = reloadReport['details']['loadedLibraryCount'];
final int finalLibraryCount = reloadReport['details']['finalLibraryCount']; final int finalLibraryCount = reloadReport['details']['finalLibraryCount'];
reloadMessage = 'Reload done: $loadedLibraryCount of $finalLibraryCount libraries needed reloading'; printTrace('reloaded $loadedLibraryCount of $finalLibraryCount libraries');
reloadMessage = '$loadedLibraryCount of $finalLibraryCount libraries';
} }
} catch (error, st) { } catch (error, st) {
final int errorCode = error['code']; final int errorCode = error['code'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment