Unverified Commit 03d6b580 authored by Mouad Debbar's avatar Mouad Debbar Committed by GitHub

[web] Allow benchmarks to customize their score keys (#51493)

parent 396e8d3e
...@@ -430,6 +430,7 @@ class Profile { ...@@ -430,6 +430,7 @@ class Profile {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return <String, dynamic>{ return <String, dynamic>{
'name': name, 'name': name,
'scoreKeys': <String>['averageDrawFrameDuration'],
'averageDrawFrameDuration': averageDrawFrameDuration.inMicroseconds, 'averageDrawFrameDuration': averageDrawFrameDuration.inMicroseconds,
'drawFrameDurationNoise': drawFrameDurationNoise, 'drawFrameDurationNoise': drawFrameDurationNoise,
'frames': frames 'frames': frames
......
...@@ -124,10 +124,33 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async { ...@@ -124,10 +124,33 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
print('Received profile data'); print('Received profile data');
for (final Map<String, dynamic> profile in profiles) { for (final Map<String, dynamic> profile in profiles) {
final String benchmarkName = profile['name'] as String; final String benchmarkName = profile['name'] as String;
final String benchmarkScoreKey = '$benchmarkName.$backend.averageDrawFrameDuration'; if (benchmarkName.isEmpty) {
taskResult[benchmarkScoreKey] = profile['averageDrawFrameDuration'].toDouble(); // micros throw 'Benchmark name is empty';
taskResult['$benchmarkName.$backend.drawFrameDurationNoise'] = profile['drawFrameDurationNoise'].toDouble(); // micros }
benchmarkScoreKeys.add(benchmarkScoreKey);
final String namespace = '$benchmarkName.$backend';
final List<String> scoreKeys = List<String>.from(profile['scoreKeys'] as List<dynamic>);
if (scoreKeys == null || scoreKeys.isEmpty) {
throw 'No score keys in benchmark "$benchmarkName"';
}
for (final String scoreKey in scoreKeys) {
if (scoreKey == null || scoreKey.isEmpty) {
throw 'Score key is empty in benchmark "$benchmarkName". '
'Received [${scoreKeys.join(', ')}]';
}
if (scoreKey.contains('.')) {
throw 'Score key contain dots in benchmark "$benchmarkName". '
'Received [${scoreKeys.join(', ')}]';
}
benchmarkScoreKeys.add('$namespace.$scoreKey');
}
for (final String key in profile.keys) {
if (key == 'name' || key == 'scoreKeys') {
continue;
}
taskResult['$namespace.$key'] = profile[key];
}
} }
return TaskResult.success(taskResult, benchmarkScoreKeys: benchmarkScoreKeys); return TaskResult.success(taskResult, benchmarkScoreKeys: benchmarkScoreKeys);
} finally { } finally {
......
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