In order to benchmark the performance of Kotlin on embedded hardware, algorithms need to be written in both C and Kotlin. The collision prediction algorithm from [Tome’s Device to Vehicle program] “D2V” is a natural choice since it is a C library with a Java native interface. The algorithm can easily be re-written in pure Kotlin, and then compared to C runtime on a PC.
The collision prediction simulation reads a CSV file containing personal safety messages (PSMs). This makes it trivial to benchmark the two versions of the algorithm. The main library is mostly based on vector math and trigonometry, which makes it straightforward to translate to Kotlin. The setup of the native Kotlin build was more complicated than expected. While the collision prediction library was successfully re-written, it was only compiled as JVM bytecode. The next step would be to complete the benchmarking by compiling the algorithm to native binaries and testing on long CSV files containing PSMs. The remaining work is enough for another lab day project.