From cf61905c04dd369f1845ee6a4f44c458b2eb19a7 Mon Sep 17 00:00:00 2001 From: Yegor Date: Tue, 13 Dec 2016 15:22:23 -0800 Subject: [PATCH] publish GPU metrics to dashboard; compact transition event printout (#7254) --- dev/devicelab/lib/tasks/gallery.dart | 3 + dev/devicelab/lib/tasks/perf_tests.dart | 3 + .../test_driver/transitions_perf_test.dart | 57 ++++++++++++++----- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/dev/devicelab/lib/tasks/gallery.dart b/dev/devicelab/lib/tasks/gallery.dart index 5ee9f3b861..9a8fdfa39c 100644 --- a/dev/devicelab/lib/tasks/gallery.dart +++ b/dev/devicelab/lib/tasks/gallery.dart @@ -61,6 +61,9 @@ class GalleryTransitionTest { 'average_frame_build_time_millis', 'worst_frame_build_time_millis', 'missed_frame_build_budget_count', + 'average_frame_rasterizer_time_millis', + 'worst_frame_rasterizer_time_millis', + 'missed_frame_rasterizer_budget_count', ]); } } diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index e3cc5b3592..0e960a83fb 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -143,6 +143,9 @@ class PerfTest { 'average_frame_build_time_millis', 'worst_frame_build_time_millis', 'missed_frame_build_budget_count', + 'average_frame_rasterizer_time_millis', + 'worst_frame_rasterizer_time_millis', + 'missed_frame_rasterizer_budget_count', ]); }); } diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index d0c699d8e0..fe54fc667d 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -60,8 +60,10 @@ final List demoTitles = [ final FileSystem _fs = new LocalFileSystem(); +/// Extracts event data from [events] recorded by timeline, validates it, turns +/// it into a histogram, and saves to a JSON file. Future saveDurationsHistogram(List> events, String outputPath) async { - final Map> durations = new Map>(); + final Map> durations = >{}; Map startEvent; // Save the duration of the first frame after each 'Start Transition' event. @@ -81,9 +83,42 @@ Future saveDurationsHistogram(List> events, String ou // Verify that the durations data is valid. if (durations.keys.isEmpty) throw 'no "Start Transition" timeline events found'; - for(String routeName in durations.keys) { - if (durations[routeName] == null || durations[routeName].length != 2) - throw 'invalid timeline data for $routeName transition'; + Map unexpectedValueCounts = {}; + durations.forEach((String routeName, List values) { + if (values.length != 2) { + unexpectedValueCounts[routeName] = values.length; + } + }); + + if (unexpectedValueCounts.isNotEmpty) { + StringBuffer error = new StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n'); + unexpectedValueCounts.forEach((String routeName, int count) { + error.writeln(' - $routeName recorded $count values.'); + }); + error.writeln('\nFull event sequence:'); + Iterator> eventIter = events.iterator; + String lastEventName = ''; + String lastRouteName = ''; + while(eventIter.moveNext()) { + String eventName = eventIter.current['name']; + + if (!['Start Transition', 'Frame'].contains(eventName)) + continue; + + String routeName = eventName == 'Start Transition' + ? eventIter.current['args']['to'] + : ''; + + if (eventName == lastEventName && routeName == lastRouteName) { + error.write('.'); + } else { + error.write('\n - $eventName $routeName .'); + } + + lastEventName = eventName; + lastRouteName = routeName; + } + throw error; } // Save the durations Map to a file. @@ -128,7 +163,8 @@ void main() { } }, streams: const [ - TimelineStream.dart + TimelineStream.dart, + TimelineStream.embedder, ]); // Save the duration (in microseconds) of the first timeline Frame event @@ -136,15 +172,8 @@ void main() { // 'Start Transition' event when a demo is launched (see GalleryItem). TimelineSummary summary = new TimelineSummary.summarize(timeline); await summary.writeSummaryToFile('transitions', pretty: true); - try { - String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json'); - await saveDurationsHistogram(timeline.json['traceEvents'], histogramPath); - } catch(_) { - await summary.writeTimelineToFile('transitions', pretty: true); - print('ERROR: failed to extract transition events. Here is the full timeline:\n'); - print(await _fs.file('$testOutputsDirectory/transitions.timeline.json').readAsString()); - rethrow; - } + String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json'); + await saveDurationsHistogram(timeline.json['traceEvents'], histogramPath); }, timeout: new Timeout(new Duration(minutes: 5))); }); }