Remove old benchmark code from the non-hot runner. (#6762)
- [x] Remove old benchmark code from the non-hot runner. - [x] Remove some dead code. - [x] Fix a throw that should be a rethrow.
This commit is contained in:
@@ -167,7 +167,7 @@ class Cache {
|
||||
await _downloadFileToCache(url, cachedFile, unzip);
|
||||
} catch (e) {
|
||||
printError('Failed to fetch third-party artifact $url: $e');
|
||||
throw e;
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/utils.dart';
|
||||
import '../build_info.dart';
|
||||
@@ -14,14 +13,10 @@ import '../device.dart';
|
||||
import '../globals.dart';
|
||||
import '../hot.dart';
|
||||
import '../ios/mac.dart';
|
||||
import '../vmservice.dart';
|
||||
import '../resident_runner.dart';
|
||||
import '../run.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import 'build_apk.dart';
|
||||
import 'daemon.dart';
|
||||
import 'install.dart';
|
||||
import 'trace.dart';
|
||||
|
||||
abstract class RunCommandBase extends FlutterCommand {
|
||||
RunCommandBase() {
|
||||
@@ -239,7 +234,6 @@ class RunCommand extends RunCommandBase {
|
||||
target: targetFile,
|
||||
debuggingOptions: options,
|
||||
traceStartup: traceStartup,
|
||||
benchmark: argResults['benchmark'],
|
||||
applicationBinary: argResults['use-application-binary']
|
||||
);
|
||||
}
|
||||
@@ -247,105 +241,3 @@ class RunCommand extends RunCommandBase {
|
||||
return runner.run(route: route, shouldBuild: !runningWithPrebuiltApplication && argResults['build']);
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> startApp(
|
||||
Device device, {
|
||||
String target,
|
||||
bool stop: true,
|
||||
bool install: true,
|
||||
DebuggingOptions debuggingOptions,
|
||||
bool traceStartup: false,
|
||||
bool benchmark: false,
|
||||
String route,
|
||||
BuildMode buildMode: BuildMode.debug
|
||||
}) async {
|
||||
String mainPath = findMainDartFile(target);
|
||||
if (!FileSystemEntity.isFileSync(mainPath)) {
|
||||
String message = 'Tried to run $mainPath, but that file does not exist.';
|
||||
if (target == null)
|
||||
message += '\nConsider using the -t option to specify the Dart file to start.';
|
||||
printError(message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ApplicationPackage package = getApplicationPackageForPlatform(device.platform);
|
||||
|
||||
if (package == null) {
|
||||
String message = 'No application found for ${device.platform}.';
|
||||
String hint = getMissingPackageHintForPlatform(device.platform);
|
||||
if (hint != null)
|
||||
message += '\n$hint';
|
||||
printError(message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch()..start();
|
||||
|
||||
// TODO(devoncarew): We shouldn't have to do type checks here.
|
||||
if (install && device is AndroidDevice) {
|
||||
printTrace('Running build command.');
|
||||
|
||||
int result = await buildApk(
|
||||
device.platform,
|
||||
target: target,
|
||||
buildMode: buildMode
|
||||
);
|
||||
|
||||
if (result != 0)
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO(devoncarew): Move this into the device.startApp() impls. They should
|
||||
// wait on the stop command to complete before (re-)starting the app. We could
|
||||
// plumb a Future through the start command from here, but that seems a little
|
||||
// messy.
|
||||
if (stop) {
|
||||
if (package != null) {
|
||||
printTrace('Stopping app "${package.name}" on ${device.name}.');
|
||||
await device.stopApp(package);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(devoncarew): This fails for ios devices - we haven't built yet.
|
||||
if (install && device is AndroidDevice) {
|
||||
printStatus('Installing $package to $device...');
|
||||
|
||||
if (!(installApp(device, package, uninstall: false)))
|
||||
return 1;
|
||||
}
|
||||
|
||||
Map<String, dynamic> platformArgs = <String, dynamic>{};
|
||||
|
||||
if (traceStartup != null)
|
||||
platformArgs['trace-startup'] = traceStartup;
|
||||
|
||||
printStatus('Running ${getDisplayPath(mainPath)} on ${device.name}...');
|
||||
|
||||
LaunchResult result = await device.startApp(
|
||||
package,
|
||||
buildMode,
|
||||
mainPath: mainPath,
|
||||
route: route,
|
||||
debuggingOptions: debuggingOptions,
|
||||
platformArgs: platformArgs
|
||||
);
|
||||
|
||||
stopwatch.stop();
|
||||
|
||||
if (!result.started) {
|
||||
printError('Error running application on ${device.name}.');
|
||||
} else if (traceStartup) {
|
||||
try {
|
||||
VMService observatory = await VMService.connect(result.observatoryPort);
|
||||
await downloadStartupTrace(observatory);
|
||||
} catch (error) {
|
||||
printError('Error downloading trace from observatory: $error');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (benchmark)
|
||||
writeRunBenchmarkFile(stopwatch);
|
||||
|
||||
return result.started ? 0 : 2;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ class RunAndStayResident extends ResidentRunner {
|
||||
DebuggingOptions debuggingOptions,
|
||||
bool usesTerminalUI: true,
|
||||
this.traceStartup: false,
|
||||
this.benchmark: false,
|
||||
this.applicationBinary
|
||||
}) : super(device,
|
||||
target: target,
|
||||
@@ -37,7 +36,6 @@ class RunAndStayResident extends ResidentRunner {
|
||||
String _mainPath;
|
||||
LaunchResult _result;
|
||||
final bool traceStartup;
|
||||
final bool benchmark;
|
||||
final String applicationBinary;
|
||||
|
||||
bool get prebuiltMode => applicationBinary != null;
|
||||
@@ -54,7 +52,6 @@ class RunAndStayResident extends ResidentRunner {
|
||||
assert(shouldBuild == !prebuiltMode);
|
||||
return _run(
|
||||
traceStartup: traceStartup,
|
||||
benchmark: benchmark,
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
appStartedCompleter: appStartedCompleter,
|
||||
route: route,
|
||||
@@ -101,7 +98,6 @@ class RunAndStayResident extends ResidentRunner {
|
||||
|
||||
Future<int> _run({
|
||||
bool traceStartup: false,
|
||||
bool benchmark: false,
|
||||
Completer<DebugConnectionInfo> connectionInfoCompleter,
|
||||
Completer<Null> appStartedCompleter,
|
||||
String route,
|
||||
@@ -194,10 +190,6 @@ class RunAndStayResident extends ResidentRunner {
|
||||
// Connect to observatory.
|
||||
if (debuggingOptions.debuggingEnabled) {
|
||||
await connectToServiceProtocol(_result.observatoryPort);
|
||||
|
||||
if (benchmark) {
|
||||
await vmService.getVM();
|
||||
}
|
||||
}
|
||||
|
||||
printTrace('Application running.');
|
||||
@@ -223,21 +215,6 @@ class RunAndStayResident extends ResidentRunner {
|
||||
|
||||
appStartedCompleter?.complete();
|
||||
|
||||
if (benchmark) {
|
||||
await new Future<Null>.delayed(new Duration(seconds: 4));
|
||||
|
||||
// Touch the file.
|
||||
File mainFile = new File(_mainPath);
|
||||
mainFile.writeAsBytesSync(mainFile.readAsBytesSync());
|
||||
|
||||
Stopwatch restartTime = new Stopwatch()..start();
|
||||
OperationResult result = await restart();
|
||||
restartTime.stop();
|
||||
writeRunBenchmarkFile(startTime, result.isOk ? restartTime : null);
|
||||
await new Future<Null>.delayed(new Duration(seconds: 2));
|
||||
stop();
|
||||
}
|
||||
|
||||
return waitForAppToFinish();
|
||||
}
|
||||
|
||||
@@ -294,15 +271,3 @@ class RunAndStayResident extends ResidentRunner {
|
||||
}
|
||||
}
|
||||
|
||||
void writeRunBenchmarkFile(Stopwatch startTime, [Stopwatch restartTime]) {
|
||||
final String benchmarkOut = 'refresh_benchmark.json';
|
||||
Map<String, dynamic> data = <String, dynamic>{
|
||||
'start': startTime.elapsedMilliseconds,
|
||||
'time': (restartTime ?? startTime).elapsedMilliseconds // time and restart are the same
|
||||
};
|
||||
if (restartTime != null)
|
||||
data['restart'] = restartTime.elapsedMilliseconds;
|
||||
|
||||
new File(benchmarkOut).writeAsStringSync(toPrettyJson(data));
|
||||
printStatus('Run benchmark written to $benchmarkOut ($data).');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user