|
![](/i/fill.gif) |
> I just ran a quick test that shows that this algorithm is actually 3
> to 4 times *slower* than Kiss64. See attached source file. Test was run
> like this:
>
> > gcc -O3 -lm -o random random.c
>
> > ./random
> Empty loop: 0ms
> Kiss64 (int): 6622ms
> Kiss64 (dbl): 5003ms
> Alvo: 21021ms
>
Interesting... I played with your test example on my system and got
rather different results. My system is much older and slower -- 32-bit
Athlon 2000+, old version of Linux & gcc. (I won't bother going into
the reasons why I still use Fedora 3, I do have and use newer versions
of Linux. But this is what I still use to read these newsgroups.)
Anyway, I had to reduce your loop count by a factor of 10 to get timings
similar to yours, but I found the Alvo was _faster_ than the Kiss64.
Then I made a couple changes, first, instead of the call to floor() I
used a simple type cast to int. Second, since the original performs the
same multiplication twice, I changed it to use a temporary variable instead.
The original relevant line:
alvo_x = (alvo_s * alvo_x) - floor (alvo_s * alvo_x);
My first change:
alvo_x = (alvo_s * alvo_x) - (int)(alvo_s * alvo_x);
My second change: (Also adding "double alvo;" to the variable list)
alvo = alvo_s * alvo_x;
alvo_x = alvo - (int)alvo;
Here are the timings on my last run:
100000000 loops:
Empty loop: 255ms
Kiss64 (int): 4568ms
Kiss64 (dbl): 8980ms
Alvo: 3626ms
Alvo: 2646ms: (int with 2 mults)
Alvo: 325ms: (int with 1 mult)
Of course, this comparison is completely irrelevant to the discussion of
RNG's for POV-Ray. I certainly don't have enough knowledge of the
subject to have an opinion about it. It also has nothing to do with the
quality of these RNGs, but I thought the differences we got for the
relative timings for this specific test example was interesting.
-=- Larry -=-
Post a reply to this message
|
![](/i/fill.gif) |