| Index: lib/src/template/utils.dart
|
| diff --git a/lib/src/template/utils.dart b/lib/src/template/utils.dart
|
| index 808ec6514c283fbe5c6b4209b395a2cdd808269d..8f68d0642fc7e47edfda1d824d6ab113d30dbffc 100644
|
| --- a/lib/src/template/utils.dart
|
| +++ b/lib/src/template/utils.dart
|
| @@ -26,7 +26,7 @@ String toCamelCase(String hyphenedName) {
|
| * whatever [callback] returns. The log message will be printed if either
|
| * [:options.showInfo:] or [printTime] are true.
|
| */
|
| -time(String logMessage, callback(), [bool printTime = false]) {
|
| +time(String logMessage, callback(), {bool printTime: false}) {
|
| final watch = new Stopwatch();
|
| watch.start();
|
| var result = callback();
|
| @@ -38,6 +38,25 @@ time(String logMessage, callback(), [bool printTime = false]) {
|
| return result;
|
| }
|
|
|
| +/**
|
| + * Invokes [callback], logs how long it takes from the moment [callback] is
|
| + * executed until the future it returns is completed. Returns the future
|
| + * returned by [callback]. The log message will be printed if either
|
| + * [:options.showInfo:] or [printTime] are true.
|
| + */
|
| +Future asyncTime(String logMessage, Future callback(),
|
| + {bool printTime: false}) {
|
| + final watch = new Stopwatch();
|
| + watch.start();
|
| + return callback()..then((_) {
|
| + watch.stop();
|
| + final duration = watch.elapsedInMs();
|
| + if (options.showInfo || printTime) {
|
| + print('$logMessage in $GREEN_COLOR$duration ms$NO_COLOR');
|
| + }
|
| + });
|
| +}
|
| +
|
| // Color constants used for generating messages.
|
| final String GREEN_COLOR = '\u001b[32m';
|
| final String RED_COLOR = '\u001b[31m';
|
|
|