adding performance test files

This commit is contained in:
JeffBezanson 2008-07-15 00:06:42 +00:00
parent b3b2bc3300
commit b0e8582c1d
3 changed files with 31 additions and 11 deletions

17
femtolisp/perf.lsp Normal file
View File

@ -0,0 +1,17 @@
(load "test.lsp")
(princ "colorgraph: ")
(load "tcolor.lsp")
(princ "fib(34): ")
(assert (equal (time (fib 34)) 5702887))
(princ "yfib(32): ")
(assert (equal (time (yfib 32)) 2178309))
(princ "sort: ")
(setq r (map-int (lambda (x) (mod (+ (* x 9421) 12345) 1024)) 1000))
(time (sort r))
(princ "mexpand: ")
(time (dotimes (n 5000) (macroexpand '(dotimes (i 100) body1 body2))))

View File

@ -8,4 +8,7 @@
(setq C (color-pairs Q '(a b c d e))) (setq C (color-pairs Q '(a b c d e)))
(dotimes (n 99) (color-pairs Q '(a b c d e)))) (dotimes (n 99) (color-pairs Q '(a b c d e))))
(time (ct)) (time (ct))
(print C) (assert (equal C '((23 . a) (9 . a) (22 . b) (17 . d) (14 . d) (8 . b) (21 . e)
(19 . b) (16 . c) (13 . c) (11 . b) (7 . e) (24 . c) (20 . d)
(18 . e) (15 . a) (12 . a) (10 . e) (6 . d) (5 . c) (4 . e)
(3 . d) (2 . c) (0 . b) (1 . a))))

View File

@ -48,9 +48,6 @@
(list piv) (list piv)
(sort (filter (lambda (x) (> x piv)) (cdr l))))))) (sort (filter (lambda (x) (> x piv)) (cdr l)))))))
;(setq r (map-int (lambda (x) (mod (+ (* x 9421) 12345) 1024)) 1000))
;(sort r)
(defmacro dotimes (var . body) (defmacro dotimes (var . body)
(let ((v (car var)) (let ((v (car var))
(cnt (cadr var))) (cnt (cadr var)))
@ -61,9 +58,7 @@
(setq ,v (+ ,v 1))))))) (setq ,v (+ ,v 1)))))))
(defmacro labl (name fn) (defmacro labl (name fn)
(list (list lambda (cons name nil) (list 'setq name fn)) nil)) `((lambda (,name) (setq ,name ,fn)) nil))
;(dotimes (n 5000) (macroexpand '(dotimes (i 100) body1 body2)))
(define (square x) (* x x)) (define (square x) (* x x))
(define (evenp x) (= x (* (/ x 2) 2))) (define (evenp x) (= x (* (/ x 2) 2)))
@ -178,6 +173,11 @@
(lambda (h) (lambda (h)
(f (lambda (x) ((h h) x))))))) (f (lambda (x) ((h h) x)))))))
(define yfib
(Y (lambda (fib)
(lambda (n)
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))))))
(defmacro debug () (defmacro debug ()
(let ((g (gensym))) (let ((g (gensym)))
`(progn (princ "Debug REPL:\n") `(progn (princ "Debug REPL:\n")
@ -188,7 +188,7 @@
identity)) identity))
(setq ,g (read)))))))) (setq ,g (read))))))))
(defun tt () (time (dotimes (i 500000) (* 0x1fffffff 1) ))) ;(defun tt () (time (dotimes (i 500000) (* 0x1fffffff 1) )))
(tt) ;(tt)
(tt) ;(tt)
(tt) ;(tt)