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

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

add glossed support echoing saved results, fix per100ms count

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