Added clock and timeit functions

Some musings with examples
This commit is contained in:
Sanel Zukan
2008-07-14 10:42:25 +00:00
parent 5a251cf812
commit af32224d5b
5 changed files with 61 additions and 11 deletions

View File

@@ -79,3 +79,16 @@
(if (= n 0)
lst
(loop (- n 1) (cons n lst)))))
;;
;; function for easier timing
;;
(define (timeit proc)
(let ((v1 0)
(v2 0))
(set! v1 (clock))
(proc)
(set! v2 (clock))
;; 1000000 is value of CLOCKS_PER_SEC
(/ (- v2 v1) 1000000)))