Commit b6ac8643 authored by Yegor's avatar Yegor Committed by GitHub

export missed transition count to the dashboard (#7426)

parent 90d18fa8
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:math' as math;
import '../framework/adb.dart'; import '../framework/adb.dart';
import '../framework/framework.dart'; import '../framework/framework.dart';
...@@ -42,10 +43,10 @@ class GalleryTransitionTest { ...@@ -42,10 +43,10 @@ class GalleryTransitionTest {
// Route paths contains slashes, which Firebase doesn't accept in keys, so we // Route paths contains slashes, which Firebase doesn't accept in keys, so we
// remove them. // remove them.
Map<String, dynamic> original = JSON.decode(file( Map<String, List<int>> original = JSON.decode(file(
'${galleryDirectory.path}/build/transition_durations.timeline.json') '${galleryDirectory.path}/build/transition_durations.timeline.json')
.readAsStringSync()); .readAsStringSync());
Map<String, dynamic> transitions = new Map<String, dynamic>.fromIterable( Map<String, List<int>> transitions = new Map<String, List<int>>.fromIterable(
original.keys, original.keys,
key: (String key) => key.replaceAll('/', ''), key: (String key) => key.replaceAll('/', ''),
value: (String key) => original[key]); value: (String key) => original[key]);
...@@ -54,10 +55,12 @@ class GalleryTransitionTest { ...@@ -54,10 +55,12 @@ class GalleryTransitionTest {
Map<String, dynamic> data = <String, dynamic>{ Map<String, dynamic> data = <String, dynamic>{
'transitions': transitions, 'transitions': transitions,
'missed_transition_count': _countMissedTransitions(transitions),
}; };
data.addAll(summary); data.addAll(summary);
return new TaskResult.success(data, benchmarkScoreKeys: <String>[ return new TaskResult.success(data, benchmarkScoreKeys: <String>[
'missed_transition_count',
'average_frame_build_time_millis', 'average_frame_build_time_millis',
'worst_frame_build_time_millis', 'worst_frame_build_time_millis',
'missed_frame_build_budget_count', 'missed_frame_build_budget_count',
...@@ -67,3 +70,16 @@ class GalleryTransitionTest { ...@@ -67,3 +70,16 @@ class GalleryTransitionTest {
]); ]);
} }
} }
int _countMissedTransitions(Map<String, List<int>> transitions) {
const int _kTransitionBudget = 100000; // µs
int count = 0;
transitions.forEach((String demoName, List<int> durations) {
int longestDuration = durations.reduce(math.max);
if (longestDuration > _kTransitionBudget) {
print('$demoName missed transition time budget ($longestDuration µs > $_kTransitionBudget µs)');
count++;
}
});
return count;
}
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