Re: speed of alloc/init for NSNumber
Re: speed of alloc/init for NSNumber
- Subject: Re: speed of alloc/init for NSNumber
- From: Nat! <email@hidden>
- Date: Sun, 18 Jan 2004 23:22:47 +0100
Am 18.01.2004 um 22:25 schrieb Chuck Soper:
It makes sense that I don't need to worry about speed with only four
hundred rows. It just seems like good practice to avoid or minimize
allocating memory in any loop. I have three or four other dictionary
keys that also require release and alloc/inits messages to be sent.
Also, I have another table that I'm about to start working on that
will have 25 to 40 thousand rows. I'm wondering at what point I need
to worry about the speed of these release and alloc/inits messages.
If you go above a very few thousand you may start worrying :)
Well to get a handle on how much time you are losing on allocation and
deallocation try code like this
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
unsigned int i, j;
NSLog( @"Start");
for( j = 0; j < 10; j++)
for( i = 0; i < 40000; i++)
[[[NSNumber alloc] initWithInt:1848] release];
NSLog(@"Stop");
[pool release];
return 0;
}
Takes 2 minutes to type and gives hard facts.
Ciao
Nat!
------------------------------------------------------
I'd like to fly
But my wings have been so denied - Cantrell
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.