Initial web benchmark harness and 3 benchmarks (#49460)

Initial web benchmark harness and 3 benchmarks
This commit is contained in:
Yegor
2020-01-30 14:19:17 -08:00
committed by GitHub
parent e7baef08a1
commit 423459da18
16 changed files with 1235 additions and 27 deletions

View File

@@ -181,10 +181,10 @@ class TaskResult {
if (benchmarkScoreKeys != null) {
for (final String key in benchmarkScoreKeys) {
if (!data.containsKey(key)) {
throw 'Invalid Golem score key "$key". It does not exist in task '
throw 'Invalid benchmark score key "$key". It does not exist in task '
'result data ${prettyJson.convert(data)}';
} else if (data[key] is! num) {
throw 'Invalid Golem score for key "$key". It is expected to be a num '
throw 'Invalid benchmark score for key "$key". It is expected to be a num '
'but was ${data[key].runtimeType}: ${prettyJson.convert(data[key])}';
}
}
@@ -212,17 +212,9 @@ class TaskResult {
/// Task-specific JSON data
final Map<String, dynamic> data;
/// Keys in [data] that store scores that will be submitted to Golem.
/// Keys in [data] that store scores that will be submitted to Cocoon.
///
/// Each key is also part of a benchmark's name tracked by Golem.
/// A benchmark name is computed by combining [Task.name] with a key
/// separated by a dot. For example, if a task's name is
/// `"complex_layout__start_up"` and score key is
/// `"engineEnterTimestampMicros"`, the score will be submitted to Golem under
/// `"complex_layout__start_up.engineEnterTimestampMicros"`.
///
/// This convention reduces the amount of configuration that needs to be done
/// to submit benchmark scores to Golem.
/// Each key is also part of a benchmark's name tracked by Cocoon.
final List<String> benchmarkScoreKeys;
/// Whether the task failed.

View File

@@ -304,7 +304,20 @@ Future<int> exec(
String workingDirectory,
}) async {
final Process process = await startProcess(executable, arguments, environment: environment, workingDirectory: workingDirectory);
await forwardStandardStreams(process);
final int exitCode = await process.exitCode;
if (exitCode != 0 && !canFail)
fail('Executable "$executable" failed with exit code $exitCode.');
return exitCode;
}
/// Forwards standard out and standard error from [process] to this process'
/// respective outputs.
///
/// Returns a future that completes when both out and error streams a closed.
Future<void> forwardStandardStreams(Process process) {
final Completer<void> stdoutDone = Completer<void>();
final Completer<void> stderrDone = Completer<void>();
process.stdout
@@ -320,13 +333,7 @@ Future<int> exec(
print('stderr: $line');
}, onDone: () { stderrDone.complete(); });
await Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
final int exitCode = await process.exitCode;
if (exitCode != 0 && !canFail)
fail('Executable "$executable" failed with exit code $exitCode.');
return exitCode;
return Future.wait<void>(<Future<void>>[stdoutDone.future, stderrDone.future]);
}
/// Executes a command and returns its standard output as a String.