Performance, part 5

In the previous articles about performance, we saw that a small fraction of the latency consisted of the mobile encrypting the data, and the target browser decrypting the data.

Waterfall diagram of encryption and decryption latency

These two steps typically take less than 100 ms. The encryption is performed on the mobile device, in the background, while the user is aiming at the QR code. The decryption happens in the target browser after the resource has been downloaded, before it can be displayed on screen.

We used third-party libraries for AES and PBKDF2, then measured how using modern “native” libraries would improve performance:

The median time for an iPhone to encrypt a 500 kB resource dropped from 41 ms to 0 ms. In this context, a 0 ms median means “more than 50% of the measurements are smaller than 1 ms”. That’s a staggering 40x speedup!

Drop in median encryption duration on iOS
Encryption duration - Smaller is better

The median time for the web page to decrypt a 500 kB resource dropped from 56 ms to 28 ms. This is an appreciable 50% speedup.

Drop in median decryption duration
Decryption duration - Smaller is better