Search⌘ K

Performance Measurement

Explore methods to measure the execution time of various thread-safe singleton implementations such as Meyers Singleton, lock guards, std::call_once, and atomics. Understand their performance across different operating systems and compilers, and analyze results to optimize concurrent singleton access in C++ programs.

We'll cover the following...

I want to measure how expensive it is to access a singleton object. For reference timing, I will use a singleton which I will access 40 million times sequentially. Of course, the first access will initialize the singleton object. In contrast, the accesses from four threads will be done concurrently. I’m only interested in the performance numbers; therefore, I will sum up the execution time of the four threads. I will measure the performance ...