benchmarks

For the Compleat Fan
Locked
Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

benchmarks

Post by Sammo »

There's a coding error in the loops benchmark. The benchmark code is (in part):

Code: Select all

(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

Code: Select all

(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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Code: Select all

(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)
)
> (time (loop1 20))
64000000
21625
> (time (loop2 20))
64000000
22359
>
For me 'for' is a little bit faster?
Hans-Peter

Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Post by Sammo »

On my 500 MHz laptop, 'dotimes' wins consistently.

Code: Select all

> (time (loop1 20)) ; for
64000000
51028
> (time (loop2 20)) ; dotimes
64000000
49876

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

> (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

Locked