Test the interface as a user sees it, and let a debug build tell on itself
Fifteen rendering tests across four files are the first tests in this project that compose a screen, and they cover the claims that used to be prose only: the app bar's star exists where there is a folder to star and says Add or Remove according to the state, the selection bar offers Rename to several files and Details only to one, the batch dialog spells out the names it will produce and refuses a collision with the file named, the shared name dialog refuses a slash while it is typed, and a favourite that has gone says "Folder not found" rather than showing a path that is not there. They run on the JVM through Robolectric - the Compose test artifacts plus the test manifest - so they belong to the same verify.sh gate as everything else instead of needing a device: 386 tests in total. Writing them turned up one behaviour worth recording. The batch dialog continues the folder's series by default, so a collision cannot be shown unless the start number is forced back to 1 - which is precisely why the feature works in practice, and now also why two of these tests set the field explicitly. The debug build now enables StrictMode (disk reads and writes, network, leaked closables; logged, not fatal) and attaches LeakCanary. A file manager is the worst possible app for a blocking disk read on the main thread, and a debug build is the last place where noticing it is still cheap. Logging rather than a crash is deliberate: turning a slow screen into a crash on someone's phone is the worse trade. The flag is read from the manifest, not from BuildConfig, which this build does not generate. Performance has a number for the first time, and it immediately paid for itself. tools/measure-startup.sh takes cold start with `am start -W` - median of several runs, one warm-up discarded because the first launch after an install pays for dexopt - and docs/PERFORMANCE.md records 1814 ms over five runs, in the debug build, which is the slow case by construction. StrictMode's first run then produced five violations against that number: 492 ms resolving `app.cacheDir` inside the view-model factory, 397 ms reading free space with StatFs for every volume inside refresh(), 477 ms of the platform loading its own typefaces, and two 54 ms OEM font hooks. That is about 1.5 s of main-thread disk I/O in a 1.8 s start, of which ~0.9 s is ours and mechanical to move. Neither of ours is fixed here on purpose: the numbers and the two fixes are recorded in PERFORMANCE.md, and they are the first items of the speed work. What is not measured is stated in the same file rather than left to be assumed: folder open at 1 000 / 5 000 / 20 000 files, thumbnail paint while scrolling, and keystroke-to-result all need a `:benchmark` module and a profileable build under the release package id, and this device waits for a confirmation dialog on the first install of a new package id. The module is deliberately absent instead of half-configured: build wiring nobody can run is worse than a recorded gap. Gate green (map current, detekt, 386 tests, lint), and CHANGELOG, README, AGENTS.md, ROADMAP, PERFORMANCE.md, EDGE_CASE_TESTING and the regenerated map carry it.
This commit is contained in:
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Cold-start baseline: installs nothing, measures the app that is already on the device.
|
||||
#
|
||||
# ./tools/measure-startup.sh # three runs
|
||||
# ./tools/measure-startup.sh 5 # five runs
|
||||
#
|
||||
# Why `am start -W` rather than a benchmark library: it needs no new module and no instrumented
|
||||
# test APK, and "time from tap to first frame" is exactly what it reports. What it does *not* do is
|
||||
# measure anything inside the app — folder open, thumbnail paint and search latency need a
|
||||
# macrobenchmark module (see docs/PERFORMANCE.md for what is still missing and why).
|
||||
set -euo pipefail
|
||||
|
||||
runs=${1:-3}
|
||||
package=de.softwareapp_hb.filemanager.debug
|
||||
component="$package/de.softwareapp_hb.filemanager.MainActivity"
|
||||
|
||||
if ! adb shell pm list packages | grep -qx "package:$package"; then
|
||||
echo "measure-startup: $package is not installed." >&2
|
||||
echo " ./gradlew :app:assembleDebug && adb install -r app/build/outputs/apk/debug/app-debug.apk" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
version=$(adb shell dumpsys package "$package" | sed -n 's/.*versionName=\([^ ]*\).*/\1/p' | head -1)
|
||||
echo "package $package ($version), $runs cold starts"
|
||||
|
||||
# One start that is thrown away. The first launch after an install pays for dexopt and JIT, and
|
||||
# folding that into a median is how a baseline gets written that nothing can meet.
|
||||
adb shell am force-stop "$package"
|
||||
sleep 1
|
||||
adb shell am start -W -n "$component" >/dev/null
|
||||
sleep 2
|
||||
|
||||
times=$(
|
||||
for run in $(seq 1 "$runs"); do
|
||||
adb shell am force-stop "$package"
|
||||
sleep 1
|
||||
adb shell am start -W -n "$component" | sed -n 's/^TotalTime: //p' | tr -d '\r'
|
||||
done | sort -n
|
||||
)
|
||||
|
||||
echo "runs (ms): $(echo "$times" | tr '\n' ' ')"
|
||||
# Median of an odd count; for an even count this takes the lower of the two middle runs, which is
|
||||
# the honest side to err on when the point is to notice a regression.
|
||||
echo "$times" | awk '
|
||||
{ value[NR] = $1 }
|
||||
END {
|
||||
printf "median: %d ms (min %d, max %d)\n", value[int((NR + 1) / 2)], value[1], value[NR]
|
||||
}
|
||||
'
|
||||
Reference in New Issue
Block a user