REBOL is on par with PERL as far as loop execution
           speed as the following simplistic tests reveal.  These
           are, of course, nothing like comprehensive benchmarks.
           (on a 300 mhz linux)

                   -jeff

----- REBOL loop speed test ---- 11 seconds

REBOL [Title: "Loop speed test"]
start: now/time 
a: 9.0 
b: 0.5 
loop 1000 [loop 1000 [c: a ** b]]

print now/time - start
quit

----- PERL loop speed test ----- 11 seconds

#!/usr/local/bin/perl
use Benchmark;

$a = 9.0;
$b = 0.5;
$t = timeit(1, '$j = 1000; while ($j--) {$i = 1000; while($i--) {$c = $a ** $b}}');

print (timestr($t),"\n");


------ C nested loops --- 5 seconds 

#include <stdio.h>
#include <math.h>

main() {
  int i = 0, j = 0;
  float a = 9.0, b = 0.5, c;

  while ( j++ < 1000 ) 
    for ( i = 0 ; i++ < 1000 ; )
      c = pow (a, b);
}


---- Elisp ------------- 1:10 and 47

   "Of course, this other interpreted language takes about a
   minute 10 seconds to complete. It only takes 47 seconds
   if it is byte compiled, though! Wowie!"

(defun loop-test ()
  (progn 
    (let ((t1 (current-time-string)))
      (setq a 9.0)
      (setq b 0.5)
      (setq i 0)
      (while (< i 1000)
        (setq i (+ i 1))
        (setq j 0)
        (while (< j 1000)
          (setq j (+ j 1))
          (setq c (expt a b))))
      (list t1 (current-time-string)))))


----- Tcl  ------ 78 seconds 

set t1 [clock seconds]
set a 9.0
set b 0.5

for {set x 0} {$x < 1000} {incr x} {
    for {set y 0} {$y < 1000} {incr y} {
        set c [expr {pow($a, $b)}]
    }
}
set t2 [clock seconds]
set t3 [expr {$t2 - $t1}]

puts $t3

Reply via email to