I'm quick with the slowness...

Published August 18, 2005
Advertisement
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.

[EDIT]

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!

[/EDIT]
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement