1*bf47c682SAndroid Build Coastguard Worker# PyWALT 2*bf47c682SAndroid Build Coastguard WorkerPython scripts for [WALT Latency Timer](https://github.com/google/walt) on Linux and ChromeOS. 3*bf47c682SAndroid Build Coastguard Worker 4*bf47c682SAndroid Build Coastguard Worker * Based on [ChromeOS scroll test implementation](https://chromium.googlesource.com/chromiumos/platform/touchbot/+/master/quickstep/) 5*bf47c682SAndroid Build Coastguard Worker * Currently supprots tap and drag (scroll) latency measurements 6*bf47c682SAndroid Build Coastguard Worker * For tests using evetest or drm (all touch and screen tests) pywalt needs to run as root 7*bf47c682SAndroid Build Coastguard Worker * In order to find the name/number of your touch device run `evtest`. It will list available input devices and once you enter a device number it will show incoming events when you touch that touchpad / touchscreen. 8*bf47c682SAndroid Build Coastguard Worker 9*bf47c682SAndroid Build Coastguard Worker 10*bf47c682SAndroid Build Coastguard WorkerSynopsis: 11*bf47c682SAndroid Build Coastguard Worker``` 12*bf47c682SAndroid Build Coastguard Worker$ walt --help 13*bf47c682SAndroid Build Coastguard Workerusage: walt [-h] [-i INPUT] [-s SERIAL] [-t TYPE] [-l LOGDIR] [-n N] [-p PORT] 14*bf47c682SAndroid Build Coastguard Worker [-d] 15*bf47c682SAndroid Build Coastguard Worker 16*bf47c682SAndroid Build Coastguard WorkerRun a latency test using WALT Latency Timer 17*bf47c682SAndroid Build Coastguard Worker 18*bf47c682SAndroid Build Coastguard Workeroptional arguments: 19*bf47c682SAndroid Build Coastguard Worker -h, --help show this help message and exit 20*bf47c682SAndroid Build Coastguard Worker -i INPUT, --input INPUT 21*bf47c682SAndroid Build Coastguard Worker input device, e.g: 6 or /dev/input/event6 (default: 22*bf47c682SAndroid Build Coastguard Worker None) 23*bf47c682SAndroid Build Coastguard Worker -s SERIAL, --serial SERIAL 24*bf47c682SAndroid Build Coastguard Worker WALT serial port (default: /dev/ttyACM0) 25*bf47c682SAndroid Build Coastguard Worker -t TYPE, --type TYPE Test type: 26*bf47c682SAndroid Build Coastguard Worker drag|tap|screen|sanity|curve|bridge|tapaudio|tapblink 27*bf47c682SAndroid Build Coastguard Worker (default: None) 28*bf47c682SAndroid Build Coastguard Worker -l LOGDIR, --logdir LOGDIR 29*bf47c682SAndroid Build Coastguard Worker where to store logs (default: /tmp) 30*bf47c682SAndroid Build Coastguard Worker -n N Number of laser toggles to read (default: 40) 31*bf47c682SAndroid Build Coastguard Worker -p PORT, --port PORT port to listen on for the TCP bridge (default: 50007) 32*bf47c682SAndroid Build Coastguard Worker -d, --debug talk more (default: False) 33*bf47c682SAndroid Build Coastguard Worker ``` 34*bf47c682SAndroid Build Coastguard Worker 35*bf47c682SAndroid Build Coastguard Worker 36*bf47c682SAndroid Build Coastguard Worker## Tap Latency ## 37*bf47c682SAndroid Build Coastguard WorkerSee the [tap latency section](../docs/usage/WALT_usage.md#tap-latency) in Android app usage doc. 38*bf47c682SAndroid Build Coastguard Worker 39*bf47c682SAndroid Build Coastguard WorkerBelow is output from an example run of a tap latency test that reads touch events from `/dev/input/event4` (in this case a touchpad). After 40 events (20 down and 20 up) are detected, the script prints median delays and exits. 40*bf47c682SAndroid Build Coastguard Worker 41*bf47c682SAndroid Build Coastguard WorkerThe input device option is mandatory since several touch devices might be preset (e.g. touchpad and touch screen). You can use a shorthand notation `-i 4` which is expanded to `-i /dev/input/event4`. 42*bf47c682SAndroid Build Coastguard Worker 43*bf47c682SAndroid Build Coastguard WorkerThe following must be run as root. 44*bf47c682SAndroid Build Coastguard Worker 45*bf47c682SAndroid Build Coastguard Worker``` 46*bf47c682SAndroid Build Coastguard Worker$ ./walt.py -t tap -n 40 -i /dev/input/event4 47*bf47c682SAndroid Build Coastguard Worker 48*bf47c682SAndroid Build Coastguard WorkerStarting tap latency test 49*bf47c682SAndroid Build Coastguard WorkerClock zeroed at 1487105210 (rt 0.250 ms) 50*bf47c682SAndroid Build Coastguard WorkerEvent: time 1487105212.048997, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1 51*bf47c682SAndroid Build Coastguard Worker 52*bf47c682SAndroid Build Coastguard Workershock t 1990338, tap t 1487105212.048997, tap val 1. dt=63738.9 53*bf47c682SAndroid Build Coastguard WorkerEvent: time 1487105212.262449, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0 54*bf47c682SAndroid Build Coastguard Worker 55*bf47c682SAndroid Build Coastguard Workershock t 2219992, tap t 1487105212.262449, tap val 0. dt=47537.0 56*bf47c682SAndroid Build Coastguard WorkerEvent: time 1487105212.702711, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1 57*bf47c682SAndroid Build Coastguard Worker 58*bf47c682SAndroid Build Coastguard Worker... 59*bf47c682SAndroid Build Coastguard Worker 60*bf47c682SAndroid Build Coastguard WorkerProcessing data... 61*bf47c682SAndroid Build Coastguard Workerdt_down = [63.74, 26.96, 27.14 ... 62*bf47c682SAndroid Build Coastguard Workerdt_up = [47.54, 47.03, 41.52... 63*bf47c682SAndroid Build Coastguard Worker 64*bf47c682SAndroid Build Coastguard WorkerMedian latency, down: 23.9, up: 47.1 65*bf47c682SAndroid Build Coastguard Worker``` 66*bf47c682SAndroid Build Coastguard Worker 67*bf47c682SAndroid Build Coastguard Worker## Drag / Scroll Latency ## 68*bf47c682SAndroid Build Coastguard WorkerSee the [drag latency section](../docs/usage/WALT_usage.md#dragscroll-latency) in Android app usage doc. 69*bf47c682SAndroid Build Coastguard Worker 70*bf47c682SAndroid Build Coastguard WorkerBelow is a drag latency measurement of the trackpad on Asus Flip. The trackpad input device is `/dev/input/event4` which was selected using the `-i 4` argument. 71*bf47c682SAndroid Build Coastguard Worker 72*bf47c682SAndroid Build Coastguard WorkerThe `-n 20` option tells the script to record 20 laser events. Any change in laser sensor reading counts as one event, therefore one crossing of the beam counts as two events (laser goes off and back on), and a full cycle of the finger going up and down counts as 4 events. This measurement recorded 20/4 = 5 full cycles of the finger moving up and down. 73*bf47c682SAndroid Build Coastguard Worker 74*bf47c682SAndroid Build Coastguard WorkerIn addition to moving your finger up and down please also move it slowly along the beam. The calculation used by pywalt needs some spread of the x coordinates for better precision. 75*bf47c682SAndroid Build Coastguard Worker 76*bf47c682SAndroid Build Coastguard WorkerDrag latency uses evtest and must therefore be run as root. 77*bf47c682SAndroid Build Coastguard Worker 78*bf47c682SAndroid Build Coastguard Worker``` 79*bf47c682SAndroid Build Coastguard Worker#./walt.py -t drag -i 4 -n 20 80*bf47c682SAndroid Build Coastguard WorkerStarting drag latency test 81*bf47c682SAndroid Build Coastguard WorkerInput device : /dev/input/event4 82*bf47c682SAndroid Build Coastguard WorkerSerial device : /dev/ttyACM1 83*bf47c682SAndroid Build Coastguard WorkerLaser log file : /tmp/WALT_2017_03_07__1532_12_laser.log 84*bf47c682SAndroid Build Coastguard Workerevtest log file: /tmp/WALT_2017_03_07__1532_12_evtest.log 85*bf47c682SAndroid Build Coastguard WorkerClock zeroed at 1488918733 (rt 0.306 ms) 86*bf47c682SAndroid Build Coastguard Worker.................... 87*bf47c682SAndroid Build Coastguard WorkerProcessing data, may take a minute or two... 88*bf47c682SAndroid Build Coastguard WorkerDrag latency (min method) = 21.07 ms 89*bf47c682SAndroid Build Coastguard Worker``` 90