Has anyone tested this in release mode builds? Or are the implementations so similar there’s no significant difference?
I’m interested in the speed to:
-
Create a new shared_ptr
-
Create a copy of the shared_ptr
-
De-reference the pointer to access the pointee
This would be in a release build optimized for speed with new shared_ptrs being created with make_shared()
Ok, so it doesn’t look like anyone has done this. Here’s what I found using the standard VC 10 optimized settings for a WIN32 console app:
Visual C++ 2010 SP1 std::make_shared and std::shared_ptr were faster than the Boost 1.46.1 equivalents when populating a vector of 10 million pointer entries ( 1.96 secs versus 0.92 secs averaged across 20 runs)
Boost 1.46.1 was slightly faster than Visual C++ 2010 SP1 when copying an array of 10 million pointer entries ( 0.15 secs versus 0.17 secs averaged over 20 runs)
Visual C++ 2010 SP1 was slightly faster than the Boost 1.46.1 equivalents when dereferencing a vector of 10 million pointer entries 20 times ( 0.72 secs versus 0.811 secs averaged over 20 runs)
CONCLUSION: There was a significant difference when creating shared_ptrs to populate a vector. The Visual C++ 2010 shared_ptr was nearly twice as fast indicating a substantial difference in implementation compared to Boost 1.46.1.
The other tests didn’t show a significant difference.
Here’s the code I used:
I’ll wait a while and if no one has refuted my results or come up with some better conclusions I’ll accept my own answer.