Atomichron
(require atomichron) | package: atomichron |
Atomichron is a microbenchmarking library. A microbenchmark is an
experiment that measures the performance of a very small and isolated piece of
code. Microbenchmarks are best used to test the performance of library
code, not real world code —
As a general rule of thumb, never write a microbenchmark to measure code that performs IO. This includes code that reads or writes files and code that talks to other computers over the network. The performance of such operations cannot be reliably reproduced or measured by Atomichron.
procedure
(microbenchmark? v) → boolean?
v : any/c
procedure
(make-microbenchmark #:iterations num-iterations #:microexpression-iterations num-microexpression-iterations #:microexpression-builder builder [ #:name name]) → microbenchmark? num-iterations : exact-positive-integer? num-microexpression-iterations : exact-positive-integer? builder : (-> natural? microexpression?) name : (or/c interned-symbol? #f) = #f
> (define num-iterations 100) > (define size 1000) > (define vec (build-vector size values)) > (define indices (build-vector num-iterations (λ (_) (random size))))
> (define vector-ref-benchmark (make-microbenchmark #:name 'vector-ref-benchmark #:iterations num-iterations #:microexpression-iterations 1000 #:microexpression-builder (λ (iteration) (define i (vector-ref indices iteration)) (make-microexpression #:thunk (λ () (vector-ref vec i)))))) > (microbenchmark-run! vector-ref-benchmark)
(microbenchmark-result
#:average-cpu-nanoseconds 10
#:average-gc-cpu-nanoseconds 0
#:average-real-nanoseconds 0
#:benchmark-name 'vector-ref-benchmark)
procedure
(microbenchmark-run! benchmark) → microbenchmark-result?
benchmark : microbenchmark?
procedure
v : any/c
procedure
(microbenchmark-result #:benchmark-name name #:average-cpu-nanoseconds cpu-nanos #:average-real-nanoseconds real-nanos #:average-gc-cpu-nanoseconds gc-nanos) → microbenchmark-result? name : (or/c interned-symbol? #f) cpu-nanos : (and/c rational? (not/c negative?)) real-nanos : (and/c rational? (not/c negative?)) gc-nanos : (and/c rational? (not/c negative?))
procedure
(microbenchmark-result-benchmark-name result)
→ (or/c interned-symbol? #f) result : microbenchmark-result?
procedure
→ (and/c rational? (not/c negative?)) result : microbenchmark-result?
procedure
→ (and/c rational? (not/c negative?)) result : microbenchmark-result?
procedure
→ (and/c rational? (not/c negative?)) result : microbenchmark-result?
procedure
(microexpression? v) → boolean?
v : any/c
procedure
(make-microexpression #:thunk thunk [ #:name name]) → microexpression? thunk : (-> any/c any) name : (or/c interned-symbol? #f) = #f