Sha256: 7ee95c298338aa7360b1e533b2e81b80b2dbfef388ce9c709b277eecd095fd01
Contents?: true
Size: 1.77 KB
Versions: 5
Compression:
Stored size: 1.77 KB
Contents
(def bm-pythag () (for i 1 50 (for j 1 50 (sqrt (+ (* i i) (* j j)))))) (def bm-repeat (f n) (for b 1 n (f))) (def bm (desc f repeats iterations) (p "\n================================================") (p "Benchmark: ~desc - ~repeats runs of ~iterations iterations each") (let times 0 (for reps 1 repeats (let time (millisecs) (bm-repeat f iterations) (let elapsed (- (millisecs) time) (assign times (+ elapsed times)) (p " took: ~elapsed ms, ~(/ elapsed iterations) ms per iteration")))) (p "total ~(just times), average ~(/ times repeats) per run") (p "================================================\n") "~desc : total ~(just times), average ~(/ times repeats) per run")) (def bm-0-arg-times-call () (*)) (def bm-1-arg-times-call () (* 23)) (def bm-2-arg-times-call () (* 23 24)) (def bm-3-arg-times-call () (* 23 24 25)) (def bm-4-arg-times-call () (* 23 24 25 26)) (def rbs (name) (let summary nil ;; (push (bm "pythag" bm-pythag 10 20) summary) ;; (push (bm "zero arg call" bm-zero-arg-call 10 100) summary) ;; (push (bm "one arg call" bm-one-arg-call 10 100) summary) ;; (push (bm "two arg call" bm-two-arg-call 10 100) summary) ;; (push (bm "three arg call" bm-three-arg-call 10 100) summary) (push (bm "0 arg times" bm-0-arg-times-call 10 10000) summary) (push (bm "1 arg times" bm-1-arg-times-call 10 10000) summary) (push (bm "2 arg times" bm-2-arg-times-call 10 10000) summary) (push (bm "3 arg times" bm-3-arg-times-call 10 10000) summary) (push (bm "4 arg times" bm-4-arg-times-call 10 10000) summary) (each s summary (p name " " s))))
Version data entries
5 entries across 5 versions & 1 rubygems