add other benchmarks

This commit is contained in:
davidly 2024-07-04 21:50:07 -07:00
parent 98aa02b895
commit 74eab1e7a6
2 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,44 @@
; Compute e to 192 digits
(setq digits 200)
(array a t digits)
(setq high digits)
(setq count 0)
(setq x 0)
(setq n (- high 1))
(defun rune() (prog ()
_nextn_
(a 1 n)
(cond ((plusp n)
(setq n (sub1 n))
(go _nextn_))
)
(a 2 1)
(a 0 0)
_nexthigh_
(setq high (sub1 high))
(setq n high)
_nextn2_
(a (mod x n) n)
(setq x (+ (* 10 (a (sub1 n))) (/ x n)))
(cond ((> n 1)
(setq n (sub1 n))
(go _nextn2_))
)
(princ x)
(cond ((> high 9)
(go _nexthigh_))
)
(return 0)
))
(setq startTime (sys:time))
(rune)
(setq endTime (sys:time))
(princ "\nelapsed seconds: ") (princ (- endTime startTime)) (princ "\n")
(exit)

View File

@ -0,0 +1,61 @@
; BYTE magazine's Sieve benchmark
(setq size 8190)
(setq sizep1 (+ size 1))
(array a t sizep1)
(setq count 0)
(setq i 0)
(setq l 0)
(defun runsieve() (prog ()
(setq i 0)
(setq count 0)
_nexti_
(cond ((< i size)
(a t i)
(setq i (add1 i))
(go _nexti_))
)
(setq i 0)
_nexti2_
(cond ((< i size)
(cond ((a i)
(setq prime (+ i i 3))
(setq k (+ i prime))
(prog ()
_nextk_
(cond ((< k size)
(a nil k)
(setq k (+ k prime))
(go _nextk_))
)
)
(setq count (add1 count)))
)
(setq i (add1 i))
(go _nexti2_))
)
))
(defun main() (prog ()
(setq startTime (sys:time))
(setq l 1)
_nextl_
(cond ((<= l 10)
(runsieve)
(princ l) (princ " ")
(setq l (add1 l))
(go _nextl_))
)
(princ "count: ") (princ count) (princ "\n")
(setq endTime (sys:time))
(princ "\nelapsed seconds: ") (princ (- endTime startTime)) (princ "\n")
))
(main)
(exit)