The difference is negligible.

void main(void)
{
   long i;
   int size;
   for(i=0;i<99999999; i++)
         size = sizeof(char *);

}

real    0m2.684s
user    0m2.690s
sys     0m0.000s


void main(void)
{
   long i;
   int size;
   int l = sizeof(char *);
   for(i=0;i<99999999; i++)
         size = l;

}

real    0m2.627s
user    0m2.620s
sys     0m0.010s

> -----Original Message-----
> From: Michael Barton [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 18, 2003 10:26 AM
> To: Chris "Winston" Litchfield; [email protected]
> Subject: Re: Simple Performance Speedup. 
> 
> 
> sizeof isn't a function anyway.  It's a unary operator 
> evaluated at compile
> time.
> Replacing all of the calls to sizeof with a variable will in 
> fact slow the
> program down, since it has to dig the value out of memory 
> every time it's
> used, instead of having a constant.
> 
> ----- Original Message ----- 
> From: "Chris "Winston" Litchfield" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Thursday, July 17, 2003 7:23 PM
> Subject: Simple Performance Speedup.
> 
> 
> > Tip of the day.
> >
> > fread_string and other fread_* functions are used a lot.  
> It would  make
> > sense that they be as fast as possible.......  it is why 
> they are using
> HASH
> > tables for string combining...
> >
> > So.. a tip of the day.
> >
> > in db.c at the top make a variable called "charptrsize" an int.
> > in boot_db do:
> > charptrsize = sizeof(char *);
> >
> > Now you are ready.. in fread_string and other 
> fread_functions that use
> > sizeof(char *) ALL OVER THE PLACE just replace it with charptrsize.
> >
> > Instant SPEEDup.  Remember each unneeded function call adds 
> a slight bit
> > slowdown.
> >
> > Chris "Winston" Litchfield
> 
> 
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
> 

Reply via email to