"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/dev/benchmarks/macrobenchmarks/lib/src/web/gallery/gallery_recorder.dart" (13 Nov 2020, 1595 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 import 'package:flutter/material.dart';
    6 
    7 import 'package:gallery/benchmarks/gallery_automator.dart';
    8 
    9 import 'package:macrobenchmarks/src/web/recorder.dart';
   10 
   11 /// A recorder that measures frame building durations for the Gallery.
   12 class GalleryRecorder extends WidgetRecorder {
   13   GalleryRecorder({
   14     @required this.benchmarkName,
   15     this.shouldRunPredicate,
   16     this.testScrollsOnly = false,
   17   }) : assert(testScrollsOnly || shouldRunPredicate != null),
   18        super(name: benchmarkName, useCustomWarmUp: true);
   19 
   20   /// The name of the gallery benchmark to be run.
   21   final String benchmarkName;
   22 
   23   /// A function that accepts the name of a demo and returns whether we should
   24   /// run this demo in this benchmark.
   25   final bool Function(String) shouldRunPredicate;
   26 
   27   /// Whether this benchmark only tests scrolling.
   28   final bool testScrollsOnly;
   29 
   30   /// Whether we should continue recording.
   31   @override
   32   bool shouldContinue() => !_finished || profile.shouldContinue();
   33 
   34   GalleryAutomator _galleryAutomator;
   35   bool get _finished => _galleryAutomator?.finished ?? false;
   36 
   37   /// Creates the [GalleryAutomator] widget.
   38   @override
   39   Widget createWidget() {
   40     _galleryAutomator = GalleryAutomator(
   41       benchmarkName: benchmarkName,
   42       shouldRunPredicate: shouldRunPredicate,
   43       testScrollsOnly: testScrollsOnly,
   44       stopWarmingUpCallback: profile.stopWarmingUp,
   45     );
   46     return _galleryAutomator.createWidget();
   47   }
   48 }