JS ARToolKit performance

Have you ever wondered how to measure the performance of ARToolKit for JavaScript (JSARToolKit) inside the web-browser? I’ve done it, and the following article will outline how I did it.

 

ARToolKit for JavaScript

JSARToolKit has been around for a few years now. There even is a direct integration with Three.js and aframe called AR.js. ARToolKit for JavaScript can basically do the same as the regular ARToolKit with the big advantage that ARToolKit for JavaScript runs in the browser and doesn’t require the installation of an app. This is made possible leveraging a technology called Emscripten. Emscripten transpiles C-Code into JavaScript code. Using this transpiled code, and a bit of glue code and voila you’ve got ARToolKit for JavaScript which is running inside your web-browser.

 

ARToolKit for JavaScript performance

When you are building an augmented reality app for the web performance becomes a very critical component. After all, you don’t want to present your users an experience that runs at less than 20 FPS. To ensure that everyone that uses ARToolKit for JavaScript enjoys it I’ve written some performance tests to measure the performance for video stream processing and single image processing.

How to write performance tests

Fortunately, I didn’t have to start on a green field because I had already written test cases for JSARToolKit. So all I had to do was take the existing functional tests and rewrite them to measure the actual performance during processing time.

This is the actual performance test:

Performance analysis step-by-step

To measure the performance the JavaScript internal performance API is used. The first performance mark (// 1. xxx) measures the time for the complete test run. Then I define a done-function that measures the clean-up time and closes the measure for the complete test run. The success function measures the actual video stream processing performance. Here you can see several performance marks that measure different states during the JSARToolKit setup and configuration process.

The most important measure is the line marked //2. xxx here I’m measuring how long it takes to process 100 frames. Processing is defined as copying the video frame over to the Emscripten transpiled JavaScript code, run the ARToolKit marker detection, identify the markerId, if marker is detected return position of the marker.

Performance results

Using the above-described process I was able to exactly determine the time it takes to configure ARToolKit and run the actual marker tracking.

JSARToolKit performance measures

JSARToolKit performance

 

All test ran on: HTC 10 | Android 8.0.0 | Model: MKQP2X/A | Serial Number: FK1QTJ8ZGRYC | Chrome 66.0.3359.158

Outlook

As you can see above there are tests for a WebAssembly version of JSARToolKit and for JSARToolKit without WebAssembly. This is another topic but while writing the tests I also enabled WebAssembly support for JSARToolKit. Make sure to check back here to get the insights about how I made that possible and don’t hesitate to ask questions below.