micro-benchmark
This egg provides means to benchmark your code in a simple manner. It features traditional benchmarking with microsecond resolution as well as a different approach that has been inspired by: https://github.com/evanphx/benchmark-ips
Documentation
Types
Usage
(import micro-benchmark)current-benchmark-iterations
current-benchmark-iterationsThe default number of iterations. Initially 100.
current-benchmark-statistics-set
current-benchmark-statistics-setThe set of generated statistics, 'verbose or 'normal.
benchmark-measure
(benchmark-measure EXPR ...) -> realRuns the EXPR ... once & returns the runtime in nanoseconds.
benchmark-run
Runs the EXPR ... ITERATIONS times and returns a micro-stats (generate-statistics) report.
ITERATIONSfixnum | true; defaults to(current-benchmark-iterations)STAT-IDsymbol | true; defaults to(current-benchmark-statistics-set)VARidentifier; variable to bind the current interation index
benchmark-ips
Determines how many times one can run the given EXPR ... per second and returns a (generate-statistics) report.
SECONDSfixnum; seconds of run while counting, defaults to5WARMUPSfixnum; seconds of run before counting, defaults to2STAT-IDsymbol; statistics set generated
benchmark-measure-run
(benchmark-measure-run ([ITERATIONS [VAR]]) EXPR ...) -> (list-of float)Returns the ITERATIONS X (EXPR ...) runtimes, in nanoseconds.
ITERATIONSfixnum | true; defaults to(current-benchmark-iterations)VARidentifier; variable to bind the current interation index
run-benchmark-measure
(run-benchmark-measure THUNK) -> realReturns the (THUNK) runtime in nanoseconds.
benchmark-measure-ips
Determines how many times one can run the given EXPR ... per second and returns a list of the iterations/second.
SECONDSreal; seconds of run while counting, defaults to5WARMUPSreal; seconds of run before counting, defaults to2
run-benchmark-ips
(run-benchmark-ips THUNK [SECONDS [WARMUPS]]) -> (list-of float)Determines how many times one can run the given (THUNK) per second and returns a list of the iterations/second.
SECONDSreal; seconds of run while counting, defaults to5WARMUPSreal; seconds of run before counting, defaults to2
current-nanoseconds
Note How unreliable time is handled is a build choice, from reliable-time, eventual-time, or warning-time. See the micro-benchmark.egg file in the source distribution.
Usage
(import current-nanoseconds)current-flnanoseconds
(current-flnanoseconds) -> floatcurrent-nanoseconds
(current-nanoseconds) -> integercurrent-microseconds
Usage
(import current-microseconds)current-flmicroseconds
(current-flmicroseconds) -> floatcurrent-microseconds
(current-microseconds) -> integerExamples
(import micro-benchmark)
;YMMV
;; simply measure the runtime of the given fragment
(benchmark-measure (sleep 2))
;=> 2003822.22601318
;; run code 3 times and return results
(parameterize ((current-benchmark-iterations 3))
(benchmark-run () (sleep 1)) )
;=> ((min . 1001227.66900635) (max . 1003503.40200806) ...)
;; find out how many iterations we can make per second
(benchmark-ips () (sleep 2))
;=> ((mean . 0.499209372899189) ...)(import micro-benchmark slib-charplot)
(parameterize ((plot-dimensions '(20 60)))
;suggest (vector-map ns->ms (benchmark-me...)) 1st
(histograph (benchmark-measure-run (40) (sleep 1))))Requirements
Authors
Repository
This egg is hosted on the CHICKEN Subversion repository:
https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/micro-benchmark
If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.
Version history
- 0.3.6
- Fix
benchmark-measure-run. - 0.3.5
- C6 release.
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.