Just a little something that has been bothering me.
James Watt
zsinwatt at qut.edu.au
Thu Dec 20 02:54:18 AEST 1990
In article <rlf.661536169 at dptspd>, rlf at dptspd.sat.datapoint.com
(Rory Foster) writes:
> sven at cs.widener.edu (Sven Heinicke) writes:
>
>>What is quicker?
>
>> int a = 0,i = 0;
>
>>or
>
>> int a,i;
>> i = a = 0;
>
>>and why?
>
>>This type of thing has been bothering me for a long time.
>
>
> Well, I looked at it and (without optimizing) the first case was "quicker".
> I was using the UNIX SVR4 C compiler. If your compiler has an assembly option,
> (-S in Johnson's PCC) use it to see for yourself.
>
> When I optimize, my compiler shows no difference. So there you have it,
> it sort of just depends on what you're using at the time.
On a HP9000 840 ( without optimisation), one is better than two, and
with optimization they are basically similar. However if you use the
int a,i=0; form of declaration and optimize it, it outperforms both
one and two. In reality there are far too many variables to make this
kind of exercise have any real relevance to the meaning of life in general.
--
|----------------------------------------------------------------------------|
| James Watt | AARnet: james at water.fit.qut.edu.au ARPA: ZSINWATT at QUT.EDU.AU |
|----------------------------------------------------------------------------|
More information about the Comp.lang.c
mailing list