cb2db9ab63
A separate package id for the app under test is the tidier design and cannot be used on this device: a new package id needs a human to approve the install every time, and installing by tapping the APK left the package listed by pm list packages yet unknown to pm enable and invisible to PackageManager. The benchmark build type therefore keeps the app's own id and takes the release key, so it updates an installed release build and keeps its data. The trade-off is stated where it happens: this build replaces a release install, and reinstalling the release APK puts it back. Two bugs surfaced on the way and both are now commented at the line they belong to. -PbenchmarkBuild was read with providers.gradleProperty, which reported it absent, so the runner installed the debug APK and failed on it; hasProperty is what works. And the reason am instrument cannot be used for this module is now recorded: MacrobenchmarkRule uninstalls the target at the start of a run and reinstalls it from the APK paths the Gradle runner passes in, so without those the app is uninstalled and left that way - which is what produced NameNotFoundException for an app that was installed a second earlier, twice, with Benchmark: Uninstalling in logcat to prove it. coldStart keeps its measured number (532 ms median). The three interaction benchmarks remain unmeasured for a reason that is now written down: each run needs one tap on the phone for the reinstall MIUI gates. Gate green, map current.
44 lines
2.0 KiB
Bash
Executable File
44 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Prepares the device for the macrobenchmark module, and takes it back afterwards.
|
|
#
|
|
# ./tools/benchmark-fixture.sh # create the folder, grant storage access
|
|
# ./tools/benchmark-fixture.sh --remove # delete the folder again
|
|
#
|
|
# Why this is a script rather than setup inside the benchmark: UiAutomation's executeShellCommand
|
|
# runs with the *test app's* uid, not the shell's, so it cannot write to /sdcard and cannot grant
|
|
# itself an app-op. The first version of the benchmark tried exactly that and failed with a
|
|
# RuntimeException from UiAutomationConnection, leaving no fixture and a hang. Through adb the same
|
|
# commands run as the shell user, which has the rights this needs.
|
|
#
|
|
# The folder is at the root of shared storage under a name that sorts before everything else, so the
|
|
# benchmark finds its row without scrolling.
|
|
set -euo pipefail
|
|
|
|
package=de.softwareapp_hb.filemanager
|
|
directory=/sdcard/AABenchmark
|
|
count=1000
|
|
|
|
case "${1:-create}" in
|
|
--remove)
|
|
adb shell "rm -rf $directory"
|
|
echo "benchmark-fixture: removed $directory"
|
|
;;
|
|
create)
|
|
# One shell loop with builtin redirection: no fork per file, so a thousand files take a moment
|
|
# rather than a minute.
|
|
adb shell "rm -rf $directory; mkdir -p $directory; \
|
|
i=0; while [ \$i -lt $count ]; do : > $directory/file-\$i.txt; i=\$((i+1)); done"
|
|
# The benchmark build is not the debug build, so it starts with no storage grant; granting it
|
|
# here is what lets the run be unattended. No `--uid`: that flag takes a uid, not a package
|
|
# name, and passing a package there grants nothing while still reporting that something was
|
|
# set — which is exactly the kind of half-truth that costs an afternoon.
|
|
adb shell "appops set $package MANAGE_EXTERNAL_STORAGE allow"
|
|
echo "benchmark-fixture: $count files in $directory, storage granted to $package"
|
|
;;
|
|
*)
|
|
echo "usage: $0 [--remove]" >&2
|
|
exit 2
|
|
;;
|
|
esac
|