[REBOL] Re: Rebol API to DyBASE
From: chris:langreiter at: 17-Dec-2003 18:13
#Bonjour Konstantin,
Wednesday, December 17, 2003, 5:30:08 PM, you wrote:
> Hello Konstantin,
> Wednesday, December 17, 2003, 7:14:02 PM, you wrote:
KK>> Hello Cyphre,
KK>> Wednesday, December 17, 2003, 6:40:03 PM, you wrote:
C>>> Hi,
C>>> I just had a quick look at
C>>> http://www.garret.ru/~knizhnik/dybase/doc/dybase.html#comparison . Is Rebol
C>>> really so slow or it is because the ported code isn't optimized to the
C>>> language yet?
KK>> Compare the following results:
KK>> Rebol: 18 seconds
KK>> h: make hash! []
KK>> start: now/time
KK>> n: 100000
KK>> for i 1 n 1 [
KK>> append h i
KK>> ]
KK>> print ["Elapsed time for" n "records" (now/time - start)]
KK>> -----------------------
KK>> Python: 0.37 seconds
KK>> import time
KK>> d = {}
KK>> start = time.time()
KK>> for i in range(0,100000):
KK>> d[i] = i
KK>> print 'Elapsed time: ', time.time() - start, ' seconds'
KK>> --------------------
KK>> PHP: 1 seconds (rounded)
KK>> <?php
KK>> $start = time();
KK>> $arr = array();
KK>> for ($i = 0; $i < 10000; $i++) {
KK>> $arr[$i] = $i;
KK>> }
KK>> print("Elapsed time: " . (time() - $start) . " seconds\n");
?>>>
> It was mistyping in PHP script - 10000 instead of 100000.
> But with 100000 iterations reported time was the same - 1 second.
> And if remove assignment to hash table and use just empty loop body
> (pure speed of interpreter), then times for 10000000 (ten millions)
> iteration are
> Python: 14 seconds
> PHP: 17 seconds
> Rebol: 58 seconds
> Also bad result (for Rebol), but 3 times slower is not 50 times slower...
That's probably because 'for is written in REBOL (enter "?? for") ;-)
start: now/time/precise
i: 0
loop 10000000 [ i: i + 1 ]
start - now/time/precise
takes only 3.5 secs.