;;;; (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))))) (define (wait-message) (gloss "Please Wait ...")) ;; (test-begin "micro-benchmark") (import micro-benchmark (only micro-stats generate-statistics)) (include "micro-benchmark-test-utils") (define-constant MS/SEC 1000000.0) (define (ms->secs x) (/ x MS/SEC)) ;NOTE (sleep i) seems to actually sleep i-1 seconds on windows #; (test-group "basic" (test-assert (glossed *iterations-overhead*)) (glossed) ) (test-group "benchmark-measure" (wait-message) (test-bigO "benchmark-measure returns runtime" MS/SEC (benchmark-measure (sleep 2))) (wait-message) (parameterize ((current-test-epsilon 0.009)) (test 1.00 (ms->secs (benchmark-measure (sleep 1)))) ) ) (parameterize ((current-test-epsilon 0.001) (current-benchmark-statistics-set #t) (current-benchmark-iterations 3) ) (test-group "benchmark-run" (let* ( (runs (begin (wait-message) (benchmark-measure-run (begin (sleep 2))))) (stats (generate-statistics runs (current-benchmark-statistics-set))) ) #;(gloss stats) (bigO-stats-tests MS/SEC stats '( max min 95th arithmetic-mean harmonic-mean geometric-mean median mode)) ) (let ((stats (benchmark-run (1) #t))) #;(gloss stats) (test "deviation for a single result" 0.0 (stats-item sd stats)) ) ) ) #; ;wait for micro-stats validation (parameterize ((current-test-epsilon 0.001) (current-benchmark-statistics-set #t) (current-benchmark-iterations 3) ) (test-group "with-expected-benchmark" (let* ( (runs (begin (wait-message) (benchmark-measure-run (begin (sleep 1))))) (stats (with-expected-benchmark w/run runs (sleep 1))) ) (gloss runs) (gloss stats) ) ) ) (parameterize ((current-test-epsilon 0.009) (current-benchmark-iterations 3) ) (test-group "examples" (import (only (chicken base) sleep)) ;simply measure the runtime of the given fragment (wait-message) (test 2.00 (ms->secs (benchmark-measure (sleep 2)))) ;run code 3 times and return results (wait-message) (test 1.00 (ms->secs (stats-item mean (benchmark-run (sleep 1))))) ;find out how many iterations we can make per second (wait-message) (test 0.5 (* 0.1 (round (* 10.0 (stats-item mean (benchmark-ips (sleep 2))))))) ) ) (test-end "micro-benchmark") (test-exit)