So I am sick at home, can't go to work. What do I do ? Code something...
I had this idea for a NSAutoreleasePool implementation, that I figured would be faster than what Foundation offers. Actually it isn't even sporting. You write down some straightforward code, measure and win. :) It's that easy. Foundation needs a little less than 2 minutes for adding securely retained objects and releasing them (the object is never ever deallocated). And the MulleAutoreleasePool code does it in 9 seconds...
2003-12-15 16:00:51.160 MulleAutoreleasePool Preparing 10000 objects... 2003-12-15 16:01:00.881 MulleAutoreleasePool Adding 100000000 objects to NSAutoreleasePool 2003-12-15 16:01:11.756 MulleAutoreleasePool Killing NSAutoreleasePool 2003-12-15 16:02:54.987 MulleAutoreleasePool Adding 100000000 objects to MulleAutoreleasePool 2003-12-15 16:02:58.324 MulleAutoreleasePool Killing MulleAutoreleasePool 2003-12-15 16:03:03.380 MulleAutoreleasePool Done
Well, well well. Things look a bit differently though, if we reduce the number of objects to a tenth. Now the MulleAutoreleasePool does it in a second, whereas Foundation "only" used 2 1/2 s.
2003-12-15 16:07:18.969 MulleAutoreleasePool Preparing 10000 objects... 2003-12-15 16:07:19.971 MulleAutoreleasePool Adding 10000000 objects to NSAutoreleasePool 2003-12-15 16:07:20.894 MulleAutoreleasePool Killing NSAutoreleasePool 2003-12-15 16:07:22.357 MulleAutoreleasePool Adding 10000000 objects to MulleAutoreleasePool 2003-12-15 16:07:22.682 MulleAutoreleasePool Killing MulleAutoreleasePool 2003-12-15 16:07:23.180 MulleAutoreleasePool Done
For whatever reason at a certain amount of objects NSAutoreleasePool really slows down a lot.
There is no point at which NSAutoreleasePool overtakes MulleAutoreleasePool. Unfortunately for me, I thought I could cleverly optimize the "releasing of the pool objects" code , but instead its my "adding an object to the pool" code that is much better.
So expect an article in the Optimizing Objective-C series sometime in the near or distant future. Though feature complete I'd like to stick the MulleAutoreleasePool in a few threaded apps and see if it behaves well. (It should).