Strata Benchmarks #1 - Elementary Functions May 16, 2019 Harshad Deo 3 minutes read Twitter Facebook Reddit LinkedIn Email Elementary functions are those that implement basic mathematical operations like exponentiation and logarithms. Swapping out numerically equivalent elementary operations is a cheap and easy way of improving runtime performance. This article presents benchmarks for three important elementary functions. These benchmarks are useful for anyone deciding whether to import a library with the complexity of Strata into their project, or use something simpler, better documented and better understood like Apache Commons Math (ACM). Three elementary functions that are useful in quantitative finance are considered in this article: Normal Distribution, which is useful for pricing a broad range of assets Normal Quantile, which is useful for inverting the price of a broad range of assets Gaussian Generator, which is necessary for Monte Carlo simulations All benchmarks were run on an AWS c5.large instance (3Ghz clock) running Ubuntu 18.04, Java 8 and gcc 7.3. Normal Distribution Five numerically equivalent implementations were considered: C++ standard library C++ standard library via JNI Strata Apache Commons Math SimianQuant The first was benchmarked in a native project, while the last four were benchmarked on the JVM. The SimianQuant implementation is proprietary. The SimianQuant implementation on the JVM is nearly as fast as the C++ implementation, while Strata’s implementation is more than six times faster than the Apache Commons Math implementation. Therefore, for all performance sensitive code, the choice is simple. Normal Quantile Four numerically equivalent implementations were considered: Boost (C++) Boost via JNI Apache Commons Math Strata The first was benchmarked in a native project, while the last three were benchmarked on the JVM. The difference in performance here is less stark, and Strata’s implementation is actually faster than the equivalent Boost implementation. Gaussian Generator Three numerically equivalent implementations were considered: C++ standard library Strata Apache Commons Math Generating random numbers is a stateful operation, and invoking the C++ generator via JNI is tricky at best. That approach was therefore not considered. All implementations used a 64-bit Mersenne Twister as the random engine. The three implementations have roughly the same performance. However, given the large number of times each generator is called, even incremental performance improvements can be significant. About Strata Strata is an award winning open source analytics and market risk library published by Open Gamma. The company, however, is opaque about its performance and that of its subcomponents. This article is the first in a series that will benchmark the library against open source alternatives and code generated using the SimianQuant library. The source code for the majority of the benchmarks can be found in the companion github repository. Other articles in this series are: Black Scholes SABR Volatility One Dimensional Interpolation Two Dimensional Interpolation Harshad The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'eureka!' but 'that's funny'.