So I tried optimizing the median function one last time by playing with the 4 level loop. From what I understood in class, reading memory along its row and iterating between rows is more efficient than reading along columns and iterating through columns. So just to be sure I slipped the third inner loop with the fourth inner loop to see how that improves performance. Well it didn’t really change performance; the test still showed numbers within the variance of the base case. To be honest, I’m pretty sure it was already reading by the row anyways. With no other ideas, I have decided to not push my changes upstream.
Although my results indicated that changing the compiler optimization option to O3 would improve the overall performance of the functions, I would only be improving the times for penguinV’s performance tests. As stated before, the libraries are not meant to be precompiled and used but included as a header file into other’s projects. This means that the compiler optimizations chosen are dependent on the recipient’s project settings. The most that changing the performance test to O3 can do is show that performance is better at O3. However, the absolute decrease in runtime is in the milliseconds and these functions are not meant to be called continuously. It is also safer for developers to see the performance at O2, which is a more stable optimization setting that their own program probably uses. Therefore, since my changes do not touch penguinV’s library primary functionalities and O3 is a less common use case than O2, I will not be making a PR with the changes.