Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
eec8d9d9
Unverified
Commit
eec8d9d9
authored
Oct 07, 2022
by
Andrew Kolos
Committed by
GitHub
Oct 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add asset manifest parsing benchmark (#112836)
parent
abca8976
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
2 deletions
+49
-2
decode_and_parse_asset_manifest.dart
...marks/lib/foundation/decode_and_parse_asset_manifest.dart
+42
-0
money_asset_manifest.json
dev/benchmarks/microbenchmarks/money_asset_manifest.json
+1
-0
pubspec.yaml
dev/benchmarks/microbenchmarks/pubspec.yaml
+1
-0
microbenchmarks.dart
dev/devicelab/lib/tasks/microbenchmarks.dart
+1
-0
image_resolution.dart
packages/flutter/lib/src/painting/image_resolution.dart
+4
-2
No files found.
dev/benchmarks/microbenchmarks/lib/foundation/decode_and_parse_asset_manifest.dart
0 → 100644
View file @
eec8d9d9
// 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
();
}
dev/benchmarks/microbenchmarks/money_asset_manifest.json
0 → 100644
View file @
eec8d9d9
This source diff could not be displayed because it is too large. You can
view the blob
instead.
dev/benchmarks/microbenchmarks/pubspec.yaml
View file @
eec8d9d9
...
...
@@ -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
...
...
dev/devicelab/lib/tasks/microbenchmarks.dart
View file @
eec8d9d9
...
...
@@ -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'
),
...
...
packages/flutter/lib/src/painting/image_resolution.dart
View file @
eec8d9d9
...
...
@@ -284,7 +284,7 @@ class AssetImage extends AssetBundleImageProvider {
Completer
<
AssetBundleImageKey
>?
completer
;
Future
<
AssetBundleImageKey
>?
result
;
chosenBundle
.
loadStructuredData
<
Map
<
String
,
List
<
String
>>?>(
_kAssetManifestFileName
,
_
manifestParser
).
then
<
void
>(
chosenBundle
.
loadStructuredData
<
Map
<
String
,
List
<
String
>>?>(
_kAssetManifestFileName
,
manifestParser
).
then
<
void
>(
(
Map
<
String
,
List
<
String
>>?
manifest
)
{
final
String
chosenName
=
_chooseVariant
(
keyName
,
...
...
@@ -328,7 +328,9 @@ class AssetImage extends AssetBundleImageProvider {
return
completer
.
future
;
}
static
Future
<
Map
<
String
,
List
<
String
>>?>
_manifestParser
(
String
?
jsonData
)
{
/// Parses the asset manifest string into a strongly-typed map.
@visibleForTesting
static
Future
<
Map
<
String
,
List
<
String
>>?>
manifestParser
(
String
?
jsonData
)
{
if
(
jsonData
==
null
)
{
return
SynchronousFuture
<
Map
<
String
,
List
<
String
>>?>(
null
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment