Add asset manifest parsing benchmark (#112836)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// Copyright 2014 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 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart' show PlatformAssetBundle;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../common.dart';
|
||||
|
||||
const int _kNumIterations = 1000;
|
||||
|
||||
void main() async {
|
||||
assert(false, "Don't run benchmarks in debug mode! Use 'flutter run --release'.");
|
||||
|
||||
final BenchmarkResultPrinter printer = BenchmarkResultPrinter();
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
final Stopwatch watch = Stopwatch();
|
||||
final PlatformAssetBundle bundle = PlatformAssetBundle();
|
||||
|
||||
final ByteData assetManifestBytes = await bundle.load('money_asset_manifest.json');
|
||||
watch.start();
|
||||
for (int i = 0; i < _kNumIterations; i++) {
|
||||
bundle.clear();
|
||||
final String json = utf8.decode(assetManifestBytes.buffer.asUint8List());
|
||||
// This is a test, so we don't need to worry about this rule.
|
||||
// ignore: invalid_use_of_visible_for_testing_member
|
||||
await AssetImage.manifestParser(json);
|
||||
}
|
||||
watch.stop();
|
||||
|
||||
printer.addResult(
|
||||
description: 'Load and Parse Large Asset Manifest',
|
||||
value: watch.elapsedMilliseconds.toDouble(),
|
||||
unit: 'ms',
|
||||
name: 'load_and_parse_large_asset_manifest',
|
||||
);
|
||||
|
||||
printer.printToStdout();
|
||||
}
|
||||
1
dev/benchmarks/microbenchmarks/money_asset_manifest.json
Normal file
1
dev/benchmarks/microbenchmarks/money_asset_manifest.json
Normal file
File diff suppressed because one or more lines are too long
@@ -70,6 +70,7 @@ dependencies:
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- money_asset_manifest.json
|
||||
- packages/flutter_gallery_assets/people/ali_landscape.png
|
||||
- packages/flutter_gallery_assets/monochrome/red-square-1024x1024.png
|
||||
- packages/flutter_gallery_assets/logos/flutter_white/logo.png
|
||||
|
||||
@@ -57,6 +57,7 @@ TaskFunction createMicrobenchmarkTask({bool enableImpeller = false}) {
|
||||
...await runMicrobench('lib/foundation/standard_message_codec_bench.dart'),
|
||||
...await runMicrobench('lib/foundation/standard_method_codec_bench.dart'),
|
||||
...await runMicrobench('lib/foundation/timeline_bench.dart'),
|
||||
...await runMicrobench('lib/foundation/decode_and_parse_asset_manifest.dart'),
|
||||
...await runMicrobench('lib/geometry/matrix_utils_transform_bench.dart'),
|
||||
...await runMicrobench('lib/geometry/rrect_contains_bench.dart'),
|
||||
...await runMicrobench('lib/gestures/gesture_detector_bench.dart'),
|
||||
|
||||
Reference in New Issue
Block a user