mirror of
https://github.com/flutter/packages.git
synced 2025-07-02 08:34:31 +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
|
## 0.1.0+7
|
||||||
|
|
||||||
* Updates `package:process` version constraints.
|
* Updates `package:process` version constraints.
|
||||||
|
@ -46,6 +46,7 @@ Future<BenchmarkResults> serveWebBenchmark({
|
|||||||
int benchmarkServerPort = defaultBenchmarkServerPort,
|
int benchmarkServerPort = defaultBenchmarkServerPort,
|
||||||
int chromeDebugPort = defaultChromeDebugPort,
|
int chromeDebugPort = defaultChromeDebugPort,
|
||||||
bool headless = true,
|
bool headless = true,
|
||||||
|
bool treeShakeIcons = true,
|
||||||
}) async {
|
}) async {
|
||||||
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
||||||
Logger.root.level = Level.INFO;
|
Logger.root.level = Level.INFO;
|
||||||
@ -57,5 +58,6 @@ Future<BenchmarkResults> serveWebBenchmark({
|
|||||||
benchmarkServerPort: benchmarkServerPort,
|
benchmarkServerPort: benchmarkServerPort,
|
||||||
chromeDebugPort: chromeDebugPort,
|
chromeDebugPort: chromeDebugPort,
|
||||||
headless: headless,
|
headless: headless,
|
||||||
|
treeShakeIcons: treeShakeIcons,
|
||||||
).run();
|
).run();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ class BenchmarkServer {
|
|||||||
required this.benchmarkServerPort,
|
required this.benchmarkServerPort,
|
||||||
required this.chromeDebugPort,
|
required this.chromeDebugPort,
|
||||||
required this.headless,
|
required this.headless,
|
||||||
|
required this.treeShakeIcons,
|
||||||
});
|
});
|
||||||
|
|
||||||
final ProcessManager _processManager = const LocalProcessManager();
|
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.
|
/// This is useful in environments (e.g. CI) that doesn't have a display.
|
||||||
final bool headless;
|
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.
|
/// Builds and serves the benchmark app, and collects benchmark results.
|
||||||
Future<BenchmarkResults> run() async {
|
Future<BenchmarkResults> run() async {
|
||||||
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
// Reduce logging level. Otherwise, package:webkit_inspection_protocol is way too spammy.
|
||||||
@ -101,6 +107,7 @@ class BenchmarkServer {
|
|||||||
'web',
|
'web',
|
||||||
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
|
'--dart-define=FLUTTER_WEB_ENABLE_PROFILING=true',
|
||||||
if (useCanvasKit) '--dart-define=FLUTTER_WEB_USE_SKIA=true',
|
if (useCanvasKit) '--dart-define=FLUTTER_WEB_USE_SKIA=true',
|
||||||
|
if (!treeShakeIcons) '--no-tree-shake-icons',
|
||||||
'--profile',
|
'--profile',
|
||||||
'-t',
|
'-t',
|
||||||
entryPoint,
|
entryPoint,
|
||||||
|
@ -2,7 +2,7 @@ name: web_benchmarks
|
|||||||
description: A benchmark harness for performance-testing Flutter apps in Chrome.
|
description: A benchmark harness for performance-testing Flutter apps in Chrome.
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks
|
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
|
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:
|
environment:
|
||||||
sdk: ">=2.19.0 <4.0.0"
|
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:flutter_test/flutter_test.dart';
|
||||||
import 'package:web_benchmarks/client.dart';
|
import 'package:web_benchmarks/client.dart';
|
||||||
|
|
||||||
import '../aboutpage.dart' show backKey;
|
import '../about_page.dart' show backKey;
|
||||||
import '../homepage.dart' show aboutPageKey, textKey;
|
import '../home_page.dart' show aboutPageKey, textKey;
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
|
|
||||||
/// A recorder that measures frame building durations.
|
/// 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 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'aboutpage.dart';
|
import 'about_page.dart';
|
||||||
import 'homepage.dart';
|
import 'home_page.dart';
|
||||||
|
import 'icon_page.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@ -26,6 +27,7 @@ class MyApp extends StatelessWidget {
|
|||||||
routes: <String, WidgetBuilder>{
|
routes: <String, WidgetBuilder>{
|
||||||
'home': (_) => const HomePage(title: 'Flutter Demo Home Page'),
|
'home': (_) => const HomePage(title: 'Flutter Demo Home Page'),
|
||||||
'about': (_) => const AboutPage(),
|
'about': (_) => const AboutPage(),
|
||||||
|
'icon_generator': (_) => const IconGeneratorPage(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,9 @@ publish_to: 'none'
|
|||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.19.0 <4.0.0"
|
sdk: '>=2.19.0 <4.0.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
cupertino_icons: ^1.0.5
|
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -15,6 +15,7 @@ Future<void> main() async {
|
|||||||
benchmarkAppDirectory: Directory('testing/test_app'),
|
benchmarkAppDirectory: Directory('testing/test_app'),
|
||||||
entryPoint: 'lib/benchmarks/runner.dart',
|
entryPoint: 'lib/benchmarks/runner.dart',
|
||||||
useCanvasKit: false,
|
useCanvasKit: false,
|
||||||
|
treeShakeIcons: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (final String benchmarkName in <String>['scroll', 'page', 'tap']) {
|
for (final String benchmarkName in <String>['scroll', 'page', 'tap']) {
|
||||||
|
Reference in New Issue
Block a user