mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 14:47:22 +08:00
Add '--no-tree-shake-icons' option to BenchmarkServer
(#5186)
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
## 0.1.0+8
|
||||
|
||||
* Adds an optional parameter `treeShakeIcons` to `serveWebBenchmark`.
|
||||
* Adds a required and named parameter `treeShakeIcons` to `BenchmarkServer`.
|
||||
|
||||
## 0.1.0+7
|
||||
|
||||
* Updates `package:process` version constraints.
|
||||
|
@ -46,6 +46,7 @@ Future<BenchmarkResults> serveWebBenchmark({
|
||||
int benchmarkServerPort = defaultBenchmarkServerPort,
|
||||
int chromeDebugPort = defaultChromeDebugPort,
|
||||
bool headless = true,
|
||||
bool treeShakeIcons = true,
|
||||
}) async {
|
||||
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
||||
Logger.root.level = Level.INFO;
|
||||
@ -57,5 +58,6 @@ Future<BenchmarkResults> serveWebBenchmark({
|
||||
benchmarkServerPort: benchmarkServerPort,
|
||||
chromeDebugPort: chromeDebugPort,
|
||||
headless: headless,
|
||||
treeShakeIcons: treeShakeIcons,
|
||||
).run();
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class BenchmarkServer {
|
||||
required this.benchmarkServerPort,
|
||||
required this.chromeDebugPort,
|
||||
required this.headless,
|
||||
required this.treeShakeIcons,
|
||||
});
|
||||
|
||||
final ProcessManager _processManager = const LocalProcessManager();
|
||||
@ -84,6 +85,11 @@ class BenchmarkServer {
|
||||
/// This is useful in environments (e.g. CI) that doesn't have a display.
|
||||
final bool headless;
|
||||
|
||||
/// Whether to tree shake icons during the build.
|
||||
///
|
||||
/// When false, '--no-tree-shake-icons' will be passed as a build argument.
|
||||
final bool treeShakeIcons;
|
||||
|
||||
/// Builds and serves the benchmark app, and collects benchmark results.
|
||||
Future<BenchmarkResults> run() async {
|
||||
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
||||
@ -101,6 +107,7 @@ class BenchmarkServer {
|
||||
'web',
|
||||
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
|
||||
if (useCanvasKit) '--dart-define=FLUTTER_WEB_USE_SKIA=true',
|
||||
if (!treeShakeIcons) '--no-tree-shake-icons',
|
||||
'--profile',
|
||||
'-t',
|
||||
entryPoint,
|
||||
|
@ -2,7 +2,7 @@ name: web_benchmarks
|
||||
description: A benchmark harness for performance-testing Flutter apps in Chrome.
|
||||
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22
|
||||
version: 0.1.0+7
|
||||
version: 0.1.0+8
|
||||
|
||||
environment:
|
||||
sdk: ">=2.19.0 <4.0.0"
|
||||
|
@ -8,8 +8,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:web_benchmarks/client.dart';
|
||||
|
||||
import '../aboutpage.dart' show backKey;
|
||||
import '../homepage.dart' show aboutPageKey, textKey;
|
||||
import '../about_page.dart' show backKey;
|
||||
import '../home_page.dart' show aboutPageKey, textKey;
|
||||
import '../main.dart';
|
||||
|
||||
/// A recorder that measures frame building durations.
|
||||
|
45
packages/web_benchmarks/testing/test_app/lib/icon_page.dart
Normal file
45
packages/web_benchmarks/testing/test_app/lib/icon_page.dart
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class IconGeneratorPage extends StatefulWidget {
|
||||
const IconGeneratorPage({super.key});
|
||||
|
||||
static int defaultIconCodePoint = int.parse('0xf03f');
|
||||
|
||||
@override
|
||||
State<IconGeneratorPage> createState() => _IconGeneratorPageState();
|
||||
}
|
||||
|
||||
class _IconGeneratorPageState extends State<IconGeneratorPage> {
|
||||
int iconCodePoint = IconGeneratorPage.defaultIconCodePoint;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
onSubmitted: (String value) {
|
||||
final int codePointAsInt =
|
||||
int.tryParse(value) ?? IconGeneratorPage.defaultIconCodePoint;
|
||||
setState(() {
|
||||
iconCodePoint = codePointAsInt;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24.0),
|
||||
Icon(generateIcon(iconCodePoint)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Unless '--no-tree-shake-icons' is passed to the flutter build command,
|
||||
// the presence of this method will trigger an exception due to the use of
|
||||
// non-constant invocations of [IconData].
|
||||
IconData generateIcon(int materialIconCodePoint) => IconData(
|
||||
materialIconCodePoint,
|
||||
fontFamily: 'MaterialIcons',
|
||||
);
|
||||
}
|
@ -4,8 +4,9 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'aboutpage.dart';
|
||||
import 'homepage.dart';
|
||||
import 'about_page.dart';
|
||||
import 'home_page.dart';
|
||||
import 'icon_page.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
@ -26,6 +27,7 @@ class MyApp extends StatelessWidget {
|
||||
routes: <String, WidgetBuilder>{
|
||||
'home': (_) => const HomePage(title: 'Flutter Demo Home Page'),
|
||||
'about': (_) => const AboutPage(),
|
||||
'icon_generator': (_) => const IconGeneratorPage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -6,10 +6,9 @@ publish_to: 'none'
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.19.0 <4.0.0"
|
||||
sdk: '>=2.19.0 <4.0.0'
|
||||
|
||||
dependencies:
|
||||
cupertino_icons: ^1.0.5
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
|
@ -15,6 +15,7 @@ Future<void> main() async {
|
||||
benchmarkAppDirectory: Directory('testing/test_app'),
|
||||
entryPoint: 'lib/benchmarks/runner.dart',
|
||||
useCanvasKit: false,
|
||||
treeShakeIcons: false,
|
||||
);
|
||||
|
||||
for (final String benchmarkName in <String>['scroll', 'page', 'tap']) {
|
||||
|
Reference in New Issue
Block a user