benchmarks

Started by Sammo, February 08, 2004, 06:25:25 AM

Previous topic - Next topic

Sammo

There's a coding error in the loops benchmark. The benchmark code is (in part):(for (a 0 n)
   (for (b 0 n)
      (for (c 0 n))  <-- misplaced paren
         (for (d 0 n)
            (for (e 0 n)
               (for (f 0 n)
                  (inc 'x) )))))
It should be(for (a 0 n)
   (for (b 0 n)
      (for (c 0 n)
         (for (d 0 n)
            (for (e 0 n)
               (for (f 0 n)
                  (inc 'x) )))))) <-- moved paren

Lutz

#1
Oops, this will change the the benchmark time, I will rerun the benchmark for this and change the numbers ASAP



This was important, thankyou



Lutz

Lutz

#2
I replaced the 'for' with 'dotimes', which is also a little bit faster, because it does not need an initializer.



Lutz

HPW

#3

(define (loop1 n)
(set 'x 0)
(for (a 1 n)
   (for (b 1 n)
      (for (c 1 n)
         (for (d 1 n)
            (for (e 1 n)
               (for (f 1 n)
                  (inc 'x) ))))))
(println x)
)

(define (loop2 n)
(set 'x 0)
(dotimes (a n)
(dotimes (b n)
(dotimes (c n)
(dotimes (d n)
(dotimes (e n)
(dotimes (f n)
(inc 'x)))))))
(println x)
)


Quote
> (time (loop1 20))

64000000

21625

> (time (loop2 20))

64000000

22359

>


For me 'for' is a little bit faster?
Hans-Peter

Sammo

#4
On my 500 MHz laptop, 'dotimes' wins consistently.> (time (loop1 20)) ; for
64000000
51028
> (time (loop2 20)) ; dotimes
64000000
49876

HPW

#5
Quote
> (time (loop1 20))

64000000

21610

> (time (loop2 20))

64000000

22297

> (time (loop1 20))

64000000

21390

> (time (loop2 20))

64000000

22172

>


1.8 GHZ Desktop P4
Hans-Peter