Inspired by
, I was thinking SFML could have a suite of microbenchmarks.
I have made a prototype at
https://github.com/Kojirion/SFML/tree/benchmarksThis is using GoogleBenchmark as a submodule.
These are of course only a few of SFML's classes. It will be far simpler to have these benchmarks if/when there are unit tests.These
- highlight the differences between getters that return a value in memory and those that perform a calculation.
- highlight he difference between flipping an image vertically and horizontally
- if these functions are refactored, they can serve as indication on how performance is affected
There are some differences to what Carruth did in the talk. He goes on to use perf to determine exactly what is being benchmarked, as well as using an assembly trick to prevent the optimizer from optimizing away the things he's interested in.
I have only gone as far as to use
volatile for the return value of functions. This is a different strategy (he gets a question about it towards the end of the talk) and seems sufficient for the moment, as the functions which do not return a value do not appear optimized away (note how he had to put std::vector in the loop, while in what I have written so far, the variables can be defined outside).
But I have not gone through perf/assembly to verify.
And surely it looks pretty.