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
50ea6f32
Unverified
Commit
50ea6f32
authored
Jun 05, 2019
by
Jonah Williams
Committed by
GitHub
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add benchmarks to track web size (#33892)
parent
a6e77377
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
0 deletions
+89
-0
web_size__compile_test.dart
dev/devicelab/bin/tasks/web_size__compile_test.dart
+10
-0
perf_tests.dart
dev/devicelab/lib/tasks/perf_tests.dart
+69
-0
manifest.yaml
dev/devicelab/manifest.yaml
+8
-0
compile.dart
packages/flutter_tools/lib/src/web/compile.dart
+1
-0
compile_test.dart
packages/flutter_tools/test/web/compile_test.dart
+1
-0
No files found.
dev/devicelab/bin/tasks/web_size__compile_test.dart
0 → 100644
View file @
50ea6f32
// Copyright 2019 The Chromium 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_devicelab/framework/framework.dart'
;
import
'package:flutter_devicelab/tasks/perf_tests.dart'
;
Future
<
void
>
main
()
async
{
await
task
(
createWebCompileTest
());
}
dev/devicelab/lib/tasks/perf_tests.dart
View file @
50ea6f32
...
...
@@ -74,6 +74,10 @@ TaskFunction createHelloWorldCompileTest() {
return
CompileTest
(
'
${flutterDirectory.path}
/examples/hello_world'
,
reportPackageContentSizes:
true
).
run
;
}
TaskFunction
createWebCompileTest
(
)
{
return
const
WebCompileTest
().
run
;
}
TaskFunction
createComplexLayoutCompileTest
(
)
{
return
CompileTest
(
'
${flutterDirectory.path}
/dev/benchmarks/complex_layout'
).
run
;
}
...
...
@@ -198,6 +202,71 @@ class PerfTest {
}
}
/// Measures how long it takes to compile a Flutter app to JavaScript and how
/// big the compiled code is.
class
WebCompileTest
{
const
WebCompileTest
();
Future
<
TaskResult
>
run
()
async
{
final
Map
<
String
,
Object
>
metrics
=
<
String
,
Object
>{};
await
inDirectory
<
TaskResult
>(
'
${flutterDirectory.path}
/examples/hello_world'
,
()
async
{
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
evalFlutter
(
'build'
,
options:
<
String
>[
'web'
,
'-v'
,
'--release'
,
'--no-pub'
,
]);
final
String
output
=
'
${flutterDirectory.path}
/examples/hello_world/build/web/main.dart.js'
;
await
_measureSize
(
'hello_world'
,
output
,
metrics
);
return
null
;
});
await
inDirectory
<
TaskResult
>(
'
${flutterDirectory.path}
/examples/flutter_gallery'
,
()
async
{
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
evalFlutter
(
'build'
,
options:
<
String
>[
'web'
,
'-v'
,
'--release'
,
'--no-pub'
,
]);
final
String
output
=
'
${flutterDirectory.path}
/examples/flutter_gallery/build/web/main.dart.js'
;
await
_measureSize
(
'flutter_gallery'
,
output
,
metrics
);
return
null
;
});
const
String
sampleAppName
=
'sample_flutter_app'
;
final
Directory
sampleDir
=
dir
(
'
${Directory.systemTemp.path}
/
$sampleAppName
'
);
rmTree
(
sampleDir
);
await
inDirectory
<
void
>(
Directory
.
systemTemp
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--template=app'
,
sampleAppName
]);
await
inDirectory
(
sampleDir
,
()
async
{
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
await
evalFlutter
(
'build'
,
options:
<
String
>[
'web'
,
'-v'
,
'--release'
,
'--no-pub'
,
]);
await
_measureSize
(
'basic_material_app'
,
path
.
join
(
sampleDir
.
path
,
'build/web/main.dart.js'
),
metrics
);
});
});
return
TaskResult
.
success
(
metrics
,
benchmarkScoreKeys:
metrics
.
keys
.
toList
());
}
static
Future
<
void
>
_measureSize
(
String
metric
,
String
output
,
Map
<
String
,
Object
>
metrics
)
async
{
final
ProcessResult
result
=
await
Process
.
run
(
'du'
,
<
String
>[
'-k'
,
output
]);
await
Process
.
run
(
'gzip'
,<
String
>[
'-k'
,
'9'
,
output
]);
final
ProcessResult
resultGzip
=
await
Process
.
run
(
'du'
,
<
String
>[
'-k'
,
output
+
'.gz'
]);
metrics
[
'
${metric}
_dart2js_size'
]
=
_parseDu
(
result
.
stdout
);
metrics
[
'
${metric}
_dart2js_size_gzip'
]
=
_parseDu
(
resultGzip
.
stdout
);
}
static
int
_parseDu
(
String
source
)
{
return
int
.
parse
(
source
.
split
(
RegExp
(
r'\s+'
)).
first
.
trim
());
}
}
/// Measures how long it takes to compile a Flutter app and how big the compiled
/// code is.
class
CompileTest
{
...
...
dev/devicelab/manifest.yaml
View file @
50ea6f32
...
...
@@ -338,6 +338,14 @@ tasks:
required_agent_capabilities
:
[
"
linux/android"
]
flaky
:
true
web_size__compile_test
:
description
:
>
Measures the size of a dart2js bundle.
stage
:
devicelab
required_agent_capabilities
:
[
"
linux/android"
]
flaky
:
true
# iOS on-device tests
flavors_test_ios
:
...
...
packages/flutter_tools/lib/src/web/compile.dart
View file @
50ea6f32
...
...
@@ -58,6 +58,7 @@ class WebCompiler {
target
,
'-o'
,
'
$outputPath
'
,
'-O4'
,
'--libraries-spec=
$librariesPath
'
,
];
if
(
minify
)
{
...
...
packages/flutter_tools/test/web/compile_test.dart
View file @
50ea6f32
...
...
@@ -38,6 +38,7 @@ void main() {
'lib/main.dart'
,
'-o'
,
'build/web/main.dart.js'
,
'-O4'
,
'--libraries-spec=bin/cache/flutter_web_sdk/libraries.json'
,
'-m'
,
])).
called
(
1
);
...
...
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