Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

I'm quick with the slowness...

Sign in to follow this  


Well, unfortunatelly I found out today that my smart pointers are slower than pack sloths in the desert. I ran a time analysis between a normal pointer with new and delete and my smart pointers with new and release.

In this test, I did n=1,000,000 allocations/deallocations for each run. Here are the numbers:

Run an empty loop n times: 0.031s

Loop n times allocating and deleting regular pointers: 17.298s

Loop n times allocating and releasing Smart pointers: 190.724s

Holy shit they are slow! It takes a little over 3 minutes to run! I pray that a hash map will be able to speed this up significantly, but I seriously doubt it.

I may just have to go the typicial way of inheriting them into an object base class. I really didn't want to do it this way for various reasons, but such a lack of performance is definitely taking precedence over everything else here.

I'll post again tonight with my hash map results.


Well, after trying various options, I have decided to keep it the way it is with the minor optimizations I have made. Nonetheless, I will go over the options I tried.

After a long while of learning exactly how a hash map works, I began to implement it in hopes of speeding things up significantly. Turns out it slowed it down more than anything! Because my class is a templated, I have no common comparison operator for the hash map to use therefore everything is compared by the pointer, which apparantly is very slooooowwww.

Because the only other option was google's sparse hash which was supposed to be a bit slower, I didn't bother attempting to change the datastructure any further. Instead I began to run smaller tests to get a more realistic idea of what the times would be like at a lower object rate.

I figured 100,000 objects would be a generous amount to allocate/deallocate in a given instant. The times came out only thousand's of a second apart. This, of course, is good news for me as I get to keep my smart pointers!

Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!