export missed transition count to the dashboard (#7426)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import '../framework/adb.dart';
|
||||
import '../framework/framework.dart';
|
||||
@@ -42,10 +43,10 @@ class GalleryTransitionTest {
|
||||
|
||||
// Route paths contains slashes, which Firebase doesn't accept in keys, so we
|
||||
// remove them.
|
||||
Map<String, dynamic> original = JSON.decode(file(
|
||||
Map<String, List<int>> original = JSON.decode(file(
|
||||
'${galleryDirectory.path}/build/transition_durations.timeline.json')
|
||||
.readAsStringSync());
|
||||
Map<String, dynamic> transitions = new Map<String, dynamic>.fromIterable(
|
||||
Map<String, List<int>> transitions = new Map<String, List<int>>.fromIterable(
|
||||
original.keys,
|
||||
key: (String key) => key.replaceAll('/', ''),
|
||||
value: (String key) => original[key]);
|
||||
@@ -54,10 +55,12 @@ class GalleryTransitionTest {
|
||||
|
||||
Map<String, dynamic> data = <String, dynamic>{
|
||||
'transitions': transitions,
|
||||
'missed_transition_count': _countMissedTransitions(transitions),
|
||||
};
|
||||
data.addAll(summary);
|
||||
|
||||
return new TaskResult.success(data, benchmarkScoreKeys: <String>[
|
||||
'missed_transition_count',
|
||||
'average_frame_build_time_millis',
|
||||
'worst_frame_build_time_millis',
|
||||
'missed_frame_build_budget_count',
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user