optimisation 
Author Message
 optimisation

Hello,

As an exercise, I was wondering if
I can make something faster then  :

char lTest ;
while ( lTest = Fonction ( ) )
{
        .....

Quote:
}

to be faster, I am trying to avoid
the comparison in the while.
could this work ?

for ( ; ; )
{
        char lTest = Fonction ( ) ;

        switch ( lTest )
        {
                case 0 : continue;
        }

        break ;

Quote:
}

if it doesn't, could you tell me
how to make the switch in a such way
that it won't be just a comparison,
but something faster, as an indexed array ?

thanks

--
?g ?g?
http://www.*-*-*.com/
oim 3d - surface viewer
kryptyomic - encryption scheme



Sun, 27 Jun 2004 20:15:23 GMT  
 optimisation

Quote:
> Hello,
> As an exercise, I was wondering if
> I can make something faster then  :
> char lTest ;
> while ( lTest = Fonction ( ) )
> {
>    .....
> }
> to be faster, I am trying to avoid
> the comparison in the while.
> could this work ?
> for ( ; ; )
> {
>         char lTest = Fonction ( ) ;

>         switch ( lTest )
>         {
>                 case 0 : continue;
>         }

>         break ;
> }
> if it doesn't, could you tell me
> how to make the switch in a such way
> that it won't be just a comparison,
> but something faster, as an indexed array ?

The C standard doesn't say this or that about which language construct
is faster or slower than which.
As far as ISO C cares, the compiler could insert 100 ms delays between
all function calls UNLESS there's a statement 1; between them. As long
as the flow of logic and overall effect is the same, execution time
does not matter.

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/
"We sorcerers don't like to eat our words, so to say."
   - Sparrowhawk



Sun, 27 Jun 2004 20:43:58 GMT  
 optimisation

Quote:

> Hello,

> As an exercise, I was wondering if
> I can make something faster then  :

> char lTest ;
> while ( lTest = Fonction ( ) )
> {
>    .....
> }

> to be faster, I am trying to avoid
> the comparison in the while.
> could this work ?

> for ( ; ; )
> {
>         char lTest = Fonction ( ) ;

>         switch ( lTest )
>         {
>                 case 0 : continue;
>         }

>         break ;
> }

> if it doesn't, could you tell me
> how to make the switch in a such way
> that it won't be just a comparison,
> but something faster, as an indexed array ?

Don't bother, most modern compilers do optimizations like this
for you and often better than you can express yourself in C.

The matter of performance falls outside the scope of this group.
Still it't fun to play with things like this.  Keep in mind that:
"Premature optimization is the root of all evil." Donald Knuth.

Good luck,

Kees



Sun, 27 Jun 2004 22:55:05 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ENORMOUS Pb with VC7 linker optimisation !

2. Binary tree optimisation

3. Optimisation In C and Algorithm Develpment

4. Algorithm Optimisation Thoughts - Languageh Independent Stage Of Development

5. Code optimisation

6. Sequence Points, Aliasing & Optimisation

7. OT: Code Optimisation Links

8. Code optimisation concerning pointers

9. optimisation flags

10. Optimisation techniques ???

11. Optimisation

12. Optimisation

 

 
Powered by phpBB® Forum Software