Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!bloom-beacon!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!jaffer From: jaffer@zurich.ai.mit.edu (Aubrey Jaffer) Newsgroups: comp.lang.scheme Subject: Revised Benchmark Message-ID: Date: 4 May 91 04:59:36 GMT References: <1991May2.155838.20830@bronze.ucs.indiana.edu> Sender: news@ai.mit.edu Distribution: comp.lang.scheme Organization: M.I.T. Artificial Intelligence Lab. Lines: 76 In-reply-to: jinx@zurich.ai.mit.edu's message of 2 May 91 21:46:41 GMT I have created new versions of the programs which take the number of decimal digits in a group as the second argument. This will allow the user to tailor the calculation to avoid bignums. time pi 800 4 9.3u 0.1s 0:10 94% With 4 digits per group and (declare (usual-integrations)), compiled MITScheme is now 2.7 times as fast as scm2d. MITScheme (show-time (lambda () (pi 200 4))) ==> process time: 5960; real time: 7790 scm2d (made with -O) (pi 200 4) ;Evaluation took 20966 mSec (1083 in gc) 242882 cons work scm2d (made with -O -DRECKLESS) (pi 200 4) ;Evaluation took 18666 mSec (1083 in gc) 242882 cons work RECKLESS turns off error checking. The type and error checking in scm2d accounts for 12% of its runtime. ------------------------------------------------------------------------ /* 'Spigot' algorithm origionally due to Stanly Rabinowitz */ main(c,v) int c;char **v;{ int n=200,j,m,b=2,k,t,r=1,d=5; long q; short *a; if(c>1)n=atoi(v[1]); if(c>2)d=atoi(v[2]); while(k++= i d) s))) (n (+ (quotient n d) 1)) (m (quotient (* n d 3322) 1000)) (a (make-vector (+ 1 m) 2))) (vector-set! a m 4) (do ((j 1 (+ 1 j)) (q 0 0) (b 2 (remainder q r))) ((> j n)) (do ((k m (- k 1))) ((zero? k)) (set! q (+ q (* (vector-ref a k) r))) (let ((t (+ 1 (* 2 k)))) (vector-set! a k (remainder q t)) (set! q (* k (quotient q t))))) (let ((s (number->string (+ b (quotient q r))))) (do ((l (string-length s) (+ 1 l))) ((>= l d) (display s)) (display #\0))) (display (if (zero? (modulo j 10)) #\newline #\ ))) (newline)))