1. Re: Muhahahaha

> void doit(int val)
> {
>  int i;
>  int v;
>  for(i = 0; i < 50000000; i++)
>      v = val;
> }

In any good compiler (VC++ included), the function doit will be optimised to
this:

void doit(int val) { }

Why? First the optimiser will unroll the loop (since it is a fixed number of
iterations), and determine that the 'v=val' assignment has been made
redundantly, and eliminate 49999999 assignments. Then, since there's no
loop, 'i' is not needed. finally we just have a 'v=val' function, which
doesn't return anything, so again, this will get optimised out of existence.
Finally, during the dead code elimination cycle, the doit() function calls
will be eliminated completely. Thus you're timing the delay between two
puts() statements, which really shouldn't be a long time. Try it again, but
change the function doit to something like this:

int doit(int val) {
    int i, n, v;

    // this is how many times we'll loop
    n=val*1000000

    // the loop is now a variable, so it's nature
    // is unpredictable, and unrollable
    for(i=0; i<n ; i++)

        // the inner function can't do the same thing, it
        // has to be iterative, or it will get moved out of the
        // loop
        v+=i;

    // we need to return a value, or the function is useless
    // and may still be optimised out of existence
    return v
}

And by the way, DirectX does all the time-consuming vertex transformations,
clipping, etc, and would not be the responsibility of Euphoria. I believe
the same is true in OpenGL, so your last statement is irrelevant. While the
interpreter's speed is important for a game, the rendering speed is far more
important. And in this case would be quite independent of the interpreter's
speed. Euphoria is fast, and I dare you to test this (and maybe some
other's, I don't have a C++ compiler installed right now), with timer()
added to show the actual speed difference. (Actually, this may cause an
overrun, I'm not sure, perhaps a better test would use floats?)

PS: Recommend reading the "Lava" by Irv Mullins as well

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu