Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == micro-benchmark [[toc:]] 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 <type>real : (or integer float ratnum)</type> <type>statistics-alist : (list-of (pair symbol *))</type> === Usage <enscript language=scheme> (import micro-benchmark) </enscript> === current-benchmark-iterations <parameter>current-benchmark-iterations</parameter> The default number of iterations. Initially {{100}}. === current-benchmark-statistics-set <parameter>current-benchmark-statistics-set</parameter> The set of generated statistics, {{'verbose}} or {{'normal}}. === benchmark-measure <syntax>(benchmark-measure EXPR ...) -> real</syntax> Runs the {{EXPR ...}} once & returns the runtime in microseconds. === benchmark-run <syntax>(benchmark-run [ITERATIONS] EXPR) -> statistics-alist</syntax> <syntax>(benchmark-run (ITERATIONS [STAT-ID]) EXPR ...) -> statistics-alist</syntax> Runs the {{EXPR ...}} {{ITERATIONS}} times and returns a {{micro-stats}} {{(generate-statistics)}} report. ; {{ITERATIONS}} : {{fixnum}} ; defaults to {{(current-benchmark-iterations)}} ; {{STAT-ID}} : {{symbol}} ; defaults to {{(current-benchmark-statistics-set)}} === benchmark-ips <syntax>(benchmark-ips [SECONDS] EXPR) -> statistics-alist</syntax> <syntax>(benchmark-ips ([SECONDS [WARMUPS [STAT-ID]]]) EXPR ...) -> statistics-alist</syntax> Determines how many times one can run the given {{EXPR ...}} per second and returns a {{(generate-statistics)}} report. ; {{SECONDS}} : {{fixnum}} ; seconds of run while counting, defaults to {{5}} ; {{WARMUPS}} : {{fixnum}} ; seconds of run before counting, defaults to {{2}} ; {{STAT-ID}} : {{symbol}} ; statistics set generated === benchmark-measure-run <syntax>(benchmark-measure-run ([ITERATIONS]) EXPR ...) -> (list-of float)</syntax> Returns the {{ITERATIONS}} X {{(EXPR ...)}} runtimes, in microseconds (μs). ; {{ITERATIONS}} : {{fixnum}} ; defaults to {{(current-benchmark-iterations)}} === run-benchmark-measure <procedure>(run-benchmark-measure THUNK) -> real</procedure> Returns the {{(THUNK)}} runtime in microseconds. === benchmark-measure-ips <syntax>(benchmark-measure-ips (begin EXPR ...)) -> (list-of float)</syntax> <syntax>(benchmark-measure-ips ([SECONDS [WARMUPS]]) EXPR ...) -> (list-of float)</syntax> Determines how many times one can run the given {{EXPR ...}} per second and returns a list of the iterations/second. ; {{SECONDS}} : {{real}} ; seconds of run while counting, defaults to {{5}} ; {{WARMUPS}} : {{real}} ; seconds of run before counting, defaults to {{2}} === run-benchmark-ips <procedure>(run-benchmark-ips THUNK [SECONDS [WARMUPS]]) -> (list-of float)</procedure> Determines how many times one can run the given {{(THUNK)}} per second and returns a list of the iterations/second. ; {{SECONDS}} : {{real}} ; seconds of run while counting, defaults to {{5}} ; {{WARMUPS}} : {{real}} ; seconds of run before counting, defaults to {{2}} === current-microseconds ==== Usage <enscript language=scheme> (import current-microseconds) </enscript> ==== current-flmicroseconds <procedure>(current-flmicroseconds) -> float</procedure> ==== current-microseconds <procedure>(current-microseconds) -> integer</procedure> == Examples <enscript highlight=scheme> (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) ...) </enscript> <enscript highlight=scheme> (import micro-benchmark slib-charplot) (parameterize ((plot-dimensions '(20 60))) (histograph (benchmark-measure-run (40) (sleep 1)))) </enscript> == Requirements [[micro-stats]] == Authors [[/users/david-krentzlin|David Krentzlin]] [[/users/kon-lovett|Kon Lovett]] == Repository This egg is hosted on the CHICKEN Subversion repository: [[https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/micro-benchmark|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 [[/egg-svn-checkout|this page]]. == Version history ; 0.0.16 : . ; 0.0.15 : . ; 0.0.14 : Loosen test epsilon. ; 0.0.12 : Treat ''macOS'' as a ''Unix'', add {{current-flmicroseconds}}. ; 0.0.10 : Add {{current-microseconds}} module. ; 0.0.1 : C5 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/>.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 8 from 12?