Changeset 39740 in project


Ignore:
Timestamp:
03/18/21 18:14:39 (8 weeks ago)
Author:
Kon Lovett
Message:

add with-expected-benchmark, add reliable-time "feature", restrict import

Location:
release/5/micro-benchmark/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/micro-benchmark/trunk/micro-benchmark.scm

    r39411 r39740  
    1111  (benchmark-run generate-statistics)
    1212  (benchmark-ips generate-statistics)
     13  (with-expected-benchmark generate-statistics chi-square)
    1314  run-benchmark-ips)
    1415
     
    2122  (chicken flonum)
    2223  (only (srfi 1) list-tabulate map!)
    23   micro-stats)
     24  (only micro-stats generate-statistics chi-square))
    2425
    2526(cond-expand
     
    172173;;
    173174
    174 (define (*realtime-microsecs)
    175   (let ((ÎŒs (realtime-microsecs)))
    176     (when (negative? ÎŒs) (warning "cannot retrieve time reliably"))
    177     ÎŒs ) )
     175(cond-expand
     176  (reliable-time
     177    (define *realtime-microsecs realtime-microsecs) )
     178  (else
     179    (define (*realtime-microsecs)
     180      (let ((ÎŒs (realtime-microsecs)))
     181        (when (negative? ÎŒs) (warning "cannot retrieve time reliably"))
     182        ÎŒs ) ) ) )
    178183
    179184(define-syntax benchmark-measure
     
    258263    ((benchmark-ips (?seconds ?warmups ?stat-set) ?code0 ?code1 ...)
    259264      (let ((observed (benchmark-measure-ips (?seconds ?warmups) ?code0 ?code1 ...)))
    260         (generate-statistics observed ?stat-set ) ) )
     265        (generate-statistics observed ?stat-set) ) )
    261266    ;C4 API
    262267    ((benchmark-ips ?code)
     
    268273;;
    269274
    270 #; ;FIXME
    271275(define-syntax with-expected-benchmark
    272276  (syntax-rules ()
    273277    ;
    274     ((with-expected-benchmark ?expected ?code ...)
    275       (and-let* ((stats (begin ?code ...)))
    276         () ) ) ) )
     278    ((with-expected-benchmark run ?expected ?code0 ?code1 ...)
     279      (with-expected-benchmark ?expected (begin (benchmark-measure-run () ?code0 ?code1 ...))) )
     280    ;
     281    ((with-expected-benchmark ips ?expected ?code0 ?code1 ...)
     282      (with-expected-benchmark ?expected (begin (benchmark-measure-ips () ?code0 ?code1 ...))) )
     283    ;
     284    ((with-expected-benchmark (run ?arg ...) ?expected ?code0 ?code1 ...)
     285      (with-expected-benchmark ?expected (begin (benchmark-measure-run (?arg ...) ?code0 ?code1 ...))) )
     286    ;
     287    ((with-expected-benchmark (ips ?arg ...) ?expected ?code0 ?code1 ...)
     288      (with-expected-benchmark ?expected (begin (benchmark-measure-ips (?arg ...) ?code0 ?code1 ...))) )
     289    ;incl chi-square w/ generate-statistics result 4 runs
     290    ((with-expected-benchmark ?expected (begin ?code ...))
     291      (let* (
     292        (expected ?expected)
     293        (observed (begin ?code ...))
     294        (stats (generate-statistics observed (current-benchmark-statistics-set))) )
     295        `((chi-square . ,(chi-square observed expected)) . ,stats) ) ) ) )
    277296
    278297;;
  • release/5/micro-benchmark/trunk/tests/micro-benchmark-test-utils.scm

    r39411 r39740  
    11;;;;
    2 
    3 ;;;
    42
    53;from mathh.scm
     
    119
    1210(define log10 (log-with-base 10))
    13 
    14 ;;;
    1511
    1612;;
  • release/5/micro-benchmark/trunk/tests/micro-benchmark-test.scm

    r39411 r39740  
    4444               (current-benchmark-iterations 3) )
    4545  (test-group "benchmark-run"
    46     (let (
     46    (let* (
     47      (runs
     48        (begin
     49          (wait-message)
     50          (benchmark-measure-run (begin (sleep 2)))))
    4751      (stats
    48         (let (
    49           (runs
    50             (begin
    51               (wait-message)
    52               (benchmark-measure-run (begin (sleep 2))))) )
    53           (generate-statistics runs (current-benchmark-statistics-set)))) )
     52        (generate-statistics runs (current-benchmark-statistics-set))) )
    5453      #;(gloss stats)
    5554      (bigO-stats-tests MS/SEC stats '(
    5655        max min
    5756        95th
    58         arithmetic-mean harmonic-mean geometric-mean median mode)) )
     57        arithmetic-mean harmonic-mean geometric-mean median mode))
     58      )
    5959
    6060    (let ((stats (benchmark-run (1) #t)))
    6161      #;(gloss stats)
    6262      (test "deviation for a single result" 0.0 (stats-item sd stats)) )
     63  )
     64)
     65
     66(parameterize ((current-test-epsilon 0.001)
     67               (current-benchmark-statistics-set #t)
     68               (current-benchmark-iterations 3) )
     69  (test-group "with-expected-benchmark"
     70    (let* (
     71      (runs
     72        (begin
     73          (wait-message)
     74          (benchmark-measure-run (begin (sleep 1)))))
     75      (cstats
     76        (with-expected-benchmark run runs (sleep 1))) )
     77      (gloss cstats) )
    6378  )
    6479)
Note: See TracChangeset for help on using the changeset viewer.