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
4da4ca89
Commit
4da4ca89
authored
Dec 01, 2016
by
Jason Simmons
Committed by
GitHub
Dec 01, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a devicelab test that captures memory usage metrics on Android (#7120)
parent
b670ce4b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
17 deletions
+143
-17
complex_layout_scroll_perf__memory.dart
...vicelab/bin/tasks/complex_layout_scroll_perf__memory.dart
+13
-0
adb.dart
dev/devicelab/lib/framework/adb.dart
+28
-0
runner.dart
dev/devicelab/lib/framework/runner.dart
+1
-15
utils.dart
dev/devicelab/lib/framework/utils.dart
+17
-2
perf_tests.dart
dev/devicelab/lib/tasks/perf_tests.dart
+78
-0
manifest.yaml
dev/devicelab/manifest.yaml
+6
-0
No files found.
dev/devicelab/bin/tasks/complex_layout_scroll_perf__memory.dart
0 → 100644
View file @
4da4ca89
// Copyright 2016 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
'dart:async'
;
import
'package:flutter_devicelab/tasks/perf_tests.dart'
;
import
'package:flutter_devicelab/framework/adb.dart'
;
import
'package:flutter_devicelab/framework/framework.dart'
;
Future
<
Null
>
main
()
async
{
await
task
(
createComplexLayoutScrollMemoryTest
(
os:
DeviceOperatingSystem
.
android
));
}
dev/devicelab/lib/framework/adb.dart
View file @
4da4ca89
...
...
@@ -81,6 +81,12 @@ abstract class Device {
///
/// Assumes the device doesn't have a secure unlock pattern.
Future
<
Null
>
unlock
();
/// Read memory statistics for a process.
Future
<
Map
<
String
,
dynamic
>>
getMemoryStats
(
String
packageName
);
/// Stop a process.
Future
<
Null
>
stop
(
String
packageName
);
}
class
AndroidDeviceDiscovery
implements
DeviceDiscovery
{
...
...
@@ -248,6 +254,20 @@ class AndroidDevice implements Device {
Future
<
String
>
shellEval
(
String
command
,
List
<
String
>
arguments
,
{
Map
<
String
,
String
>
env
})
{
return
eval
(
adbPath
,
<
String
>[
'shell'
,
command
]..
addAll
(
arguments
),
env:
env
,
canFail:
false
);
}
@override
Future
<
Map
<
String
,
dynamic
>>
getMemoryStats
(
String
packageName
)
async
{
String
meminfo
=
await
shellEval
(
'dumpsys'
,
<
String
>[
'meminfo'
,
packageName
]);
Match
match
=
new
RegExp
(
r'TOTAL\s+(\d+)'
).
firstMatch
(
meminfo
);
return
<
String
,
dynamic
>{
'total_kb'
:
int
.
parse
(
match
.
group
(
1
)),
};
}
@override
Future
<
Null
>
stop
(
String
packageName
)
async
{
return
shellExec
(
'am'
,
<
String
>[
'force-stop'
,
packageName
]);
}
}
class
IosDeviceDiscovery
implements
DeviceDiscovery
{
...
...
@@ -344,6 +364,14 @@ class IosDevice implements Device {
@override
Future
<
Null
>
unlock
()
async
{}
@override
Future
<
Map
<
String
,
dynamic
>>
getMemoryStats
(
String
packageName
)
async
{
throw
'Not implemented'
;
}
@override
Future
<
Null
>
stop
(
String
packageName
)
async
{}
}
/// Path to the `adb` executable.
...
...
dev/devicelab/lib/framework/runner.dart
View file @
4da4ca89
...
...
@@ -28,7 +28,7 @@ Future<Map<String, dynamic>> runTask(String taskName, { bool silent: false }) as
if
(!
file
(
taskExecutable
).
existsSync
())
throw
'Executable Dart file not found:
$taskExecutable
'
;
int
vmServicePort
=
await
_
findAvailablePort
();
int
vmServicePort
=
await
findAvailablePort
();
Process
runner
=
await
startProcess
(
dartBin
,
<
String
>[
'--enable-vm-service=
$vmServicePort
'
,
'--no-pause-isolates-on-exit'
,
...
...
@@ -118,17 +118,3 @@ Future<VMIsolate> _connectToRunnerIsolate(int vmServicePort) async {
}
}
}
Future
<
int
>
_findAvailablePort
()
async
{
int
port
=
20000
;
while
(
true
)
{
try
{
ServerSocket
socket
=
await
ServerSocket
.
bind
(
InternetAddress
.
LOOPBACK_IP_V4
,
port
);
await
socket
.
close
();
return
port
;
}
catch
(
_
)
{
port
++;
}
}
}
dev/devicelab/lib/framework/utils.dart
View file @
4da4ca89
...
...
@@ -231,10 +231,10 @@ Future<String> eval(String executable, List<String> arguments,
}
Future
<
int
>
flutter
(
String
command
,
{
List
<
String
>
options:
const
<
String
>[],
bool
canFail:
false
})
{
{
List
<
String
>
options:
const
<
String
>[],
bool
canFail:
false
,
Map
<
String
,
String
>
env
})
{
List
<
String
>
args
=
<
String
>[
command
]..
addAll
(
options
);
return
exec
(
path
.
join
(
flutterDirectory
.
path
,
'bin'
,
'flutter'
),
args
,
canFail:
canFail
);
canFail:
canFail
,
env:
env
);
}
String
get
dartBin
=>
...
...
@@ -404,3 +404,18 @@ Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) {
});
return
completer
.
future
;
}
/// Return an unused TCP port number.
Future
<
int
>
findAvailablePort
()
async
{
int
port
=
20000
;
while
(
true
)
{
try
{
ServerSocket
socket
=
await
ServerSocket
.
bind
(
InternetAddress
.
LOOPBACK_IP_V4
,
port
);
await
socket
.
close
();
return
port
;
}
catch
(
_
)
{
port
++;
}
}
}
dev/devicelab/lib/tasks/perf_tests.dart
View file @
4da4ca89
...
...
@@ -20,6 +20,16 @@ TaskFunction createComplexLayoutScrollPerfTest({ @required DeviceOperatingSystem
);
}
TaskFunction
createComplexLayoutScrollMemoryTest
(
{
@required
DeviceOperatingSystem
os
})
{
return
new
MemoryTest
(
'
${flutterDirectory.path}
/dev/benchmarks/complex_layout'
,
'test_driver/scroll_perf.dart'
,
'complex_layout_scroll_perf'
,
'com.yourcompany.complexLayout'
,
os:
os
,
);
}
TaskFunction
createFlutterGalleryStartupTest
(
{
@required
DeviceOperatingSystem
os
})
{
return
new
StartupTest
(
'
${flutterDirectory.path}
/examples/flutter_gallery'
,
...
...
@@ -173,3 +183,71 @@ class BuildTest {
});
}
}
class
MemoryTest
{
MemoryTest
(
this
.
testDirectory
,
this
.
testTarget
,
this
.
timelineFileName
,
this
.
packageName
,
{
this
.
os
});
final
String
testDirectory
;
final
String
testTarget
;
final
String
timelineFileName
;
final
String
packageName
;
final
DeviceOperatingSystem
os
;
Future
<
TaskResult
>
call
()
{
return
inDirectory
(
testDirectory
,
()
async
{
Device
device
=
await
devices
.
workingDevice
;
await
device
.
unlock
();
String
deviceId
=
device
.
deviceId
;
await
flutter
(
'packages'
,
options:
<
String
>[
'get'
]);
if
(
os
==
DeviceOperatingSystem
.
ios
)
{
// This causes an Xcode project to be created.
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--profile'
]);
}
int
debugPort
=
await
findAvailablePort
();
await
flutter
(
'run'
,
options:
<
String
>[
'-v'
,
'--profile'
,
'--trace-startup'
,
// wait for the first frame to render
'-t'
,
testTarget
,
'-d'
,
deviceId
,
'--debug-port'
,
debugPort
.
toString
(),
]);
Map
<
String
,
dynamic
>
startData
=
await
device
.
getMemoryStats
(
packageName
);
await
flutter
(
'drive'
,
options:
<
String
>[
'-v'
,
'-t'
,
testTarget
,
'-d'
,
deviceId
,
'--use-existing-app'
,
//'--keep-app-running',
],
env:
<
String
,
String
>
{
'VM_SERVICE_URL'
:
'http://localhost:
$debugPort
'
});
Map
<
String
,
dynamic
>
endData
=
await
device
.
getMemoryStats
(
packageName
);
Map
<
String
,
dynamic
>
data
=
<
String
,
dynamic
>{
'start_total_kb'
:
startData
[
'total_kb'
],
'end_total_kb'
:
endData
[
'total_kb'
],
'diff_total_kb'
:
endData
[
'total_kb'
]
-
startData
[
'total_kb'
],
};
await
device
.
stop
(
packageName
);
return
new
TaskResult
.
success
(
data
,
benchmarkScoreKeys:
<
String
>[
'start_total_kb'
,
'end_total_kb'
,
'diff_total_kb'
,
]);
});
}
}
dev/devicelab/manifest.yaml
View file @
4da4ca89
...
...
@@ -109,6 +109,12 @@ tasks:
stage
:
devicelab
required_agent_capabilities
:
[
"
has-android-device"
]
complex_layout_scroll_perf__memory
:
description
:
>
Measures memory usage of the scroll performance test.
stage
:
devicelab
required_agent_capabilities
:
[
"
has-android-device"
]
# iOS on-device tests
...
...
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