DEV Community

Will Blaschko
Will Blaschko

Posted on

Alexa APL Performance Benchmark

Falling Blocks Game
(The above is a layout used to stress-test APL)

Rhetorical question: have you ever wanted to benchmark the load times for different Alexa APL documents? To be able to A/B/C/… test them to understand which implementation would give the quickest render time for your customers?

Hopefully the answer is: “Absolutely!”

Here’s some code you can use to benchmark both in the browser and on a physical device.

Requirements:

How it works:
Puppeteer opens the Displays Simulator and renders the layouts/data repeatedly. Each time the browser renders the layout, a command is also (optionally) sent to the Fire TV through ADB. Listening to web console logs (simulator) and ADB logs (Fire TV), the script calculates the time of each render.

How to Use:

  1. Configure index.js to meet your needs, currently everything is defined in code, but it could be modified to be command line arguments.
  2. If using Fire TV, adb connect … to the target device.
  3. Copy a valid Chromium user directory to an accessible folder and use as a parameter (or change benchmark.js to log in automatically).

What This Is:
This is meant to be a proof-of-concept experiment as I optimize my own documents. I hope someone can use this as a starting point for a more comprehensive tool.

Files:
index.js - Launch benchmark and output performance
benchmark.js - Benchmark library
package.json - Node package
layout_base.json - Default layout used to reset the simulator
layout_example_*.json - Different layouts to benchmark
data_example.json - Data used for all layouts

Sample Output:
Running benchmark for Layout 0 (Browser)
Benchmark ran 100 times.
Average render: 1723ms
Max render: 3989ms
Min render: 236ms

Running benchmark for Layout 1 (Browser)
Benchmark ran 100 times.
Average render: 1786ms
Max render: 3326ms
Min render: 224ms

Top comments (0)