;;;; (import test) (include "test-gloss.incl") (define glossed (let ((saved #f)) (lambda (#!optional (x (void))) (if (eq? x (void)) (gloss saved) (begin (set! saved x) x))))) (test-begin "micro-benchmark") (import micro-benchmark) (include "micro-benchmark-test-utils") ;; (import (only micro-stats generate-statistics)) (test-begin "micro-benchmark") (test-assert (glossed *iterations-overhead*)) (glossed) (test-group "examples" (import (only (chicken base) sleep)) ;simply measure the runtime of the given fragment (test-assert (glossed (benchmark-measure (sleep 2)))) (glossed) ;run code 3 times and return results (parameterize ((current-benchmark-iterations 3)) (test-assert (glossed (benchmark-run (sleep 1)))) (glossed)) ;find out how many iterations we can make per second (test-assert (glossed (benchmark-ips (sleep 2)))) (glossed) ) (parameterize ((current-test-epsilon 0.001) (current-benchmark-statistics-set #t) ) ; (gloss "Please Wait") (test-bigO "benchmark-measure returns runtime" 1000000.0 (benchmark-measure (busy-work) 'test)) ; (test-group "benchmark-run" (let ( (stats (let ( (runs (parameterize ((current-benchmark-iterations 3)) (gloss "Please Wait") (benchmark-measure-run (begin (busy-work) 'test)))) ) (generate-statistics runs (current-benchmark-statistics-set)))) ) #;(gloss stats) (bigO-stats-tests 1000000.0 stats '( max min 95th arithmetic-mean harmonic-mean geometric-mean median mode)) ) ; (let ((stats (benchmark-run (1) #t))) (test "deviation for a single result" 0.0 (stats-item sd stats)) #;(gloss stats) ) ) ) (test-end "micro-benchmark") (test-exit)