source: project/release/5/micro-benchmark/trunk/tests/micro-benchmark-test.scm @ 39379

Last change on this file since 39379 was 39379, checked in by Kon Lovett, 6 months ago

remove -lrt (?), common waitmsg

File size: 1.9 KB
Line 
1;;;;
2
3(import test)
4(include "test-gloss.incl")
5
6(define glossed
7  (let ((saved #f))
8    (lambda (#!optional (x (void)))
9      (if (eq? x (void))
10        (gloss saved)
11        (begin (set! saved x) x)))))
12
13(define (wait-message) (gloss "Please Wait ..."))
14
15(test-begin "micro-benchmark")
16
17(import micro-benchmark)
18(include "micro-benchmark-test-utils")
19
20;;
21
22(import (only micro-stats generate-statistics))
23
24(test-begin "micro-benchmark")
25
26(test-group "basic"
27  (test-assert (glossed *iterations-overhead*))
28  (glossed)
29)
30
31(test-group "examples"
32  (import (only (chicken base) sleep))
33
34  ;simply measure the runtime of the given fragment
35  (wait-message)
36  (test-assert (glossed (benchmark-measure (sleep 2))))
37  (glossed)
38
39  ;run code 3 times and return results
40  (wait-message)
41  (parameterize ((current-benchmark-iterations 3))
42    (test-assert (glossed (benchmark-run (sleep 1))))
43    (glossed))
44
45  ;find out how many iterations we can make per second
46  (wait-message)
47  (test-assert (glossed (benchmark-ips (sleep 2))))
48  (glossed)
49)
50
51(parameterize ((current-test-epsilon 0.001)
52               (current-benchmark-statistics-set #t) )
53  ;
54  (wait-message)
55  (test-bigO "benchmark-measure returns runtime"
56    1000000.0 (benchmark-measure (busy-work) 'test))
57  ;
58  (test-group "benchmark-run"
59    (let (
60      (stats
61        (let (
62          (runs
63            (parameterize ((current-benchmark-iterations 3))
64              (wait-message)
65              (benchmark-measure-run (begin (busy-work) 'test)))) )
66          (generate-statistics runs (current-benchmark-statistics-set)))) )
67      #;(gloss stats)
68      (bigO-stats-tests 1000000.0 stats '(
69        max min
70        95th
71        arithmetic-mean harmonic-mean geometric-mean median mode)) )
72    ;
73    (let ((stats (benchmark-run (1) #t)))
74      (test "deviation for a single result" 0.0 (stats-item sd stats))
75      #;(gloss stats) )
76  )
77)
78
79(test-end "micro-benchmark")
80
81(test-exit)
Note: See TracBrowser for help on using the repository browser.