source: project/wiki/eggref/4/micro-benchmark @ 30894

Last change on this file since 30894 was 30894, checked in by certainty, 6 years ago

micro-benchmark: fixed link

File size: 2.4 KB
Line 
1== micro-benchmark
2[[toc:]]
3
4=== Repository
5
6[[https://bitbucket.org/certainty/micro-benchmark/overview]]
7
8
9=== Authors
10[[/users/david-krentzlin|David Krentzlin]]
11
12
13=== Introduction
14
15This egg provides means to benchmark your code in a simple manner. It features traditional benchmarking with microsecond
16resultion as well as a different approach that has been inspired by: [[https://github.com/evanphx/benchmark-ips]]
17
18
19
20=== Examples
21
22<enscript highlight=scheme>
23(use micro-benchmark)
24
25;; simply measure the runtime of the given fragment
26(benchmark-measure (sleep 2))
27
28;; run code 3 times and return results
29(parameterize ((current-benchmark-iterations 3))
30  (benchmark-run (sleep 1)))
31
32;; find out how many iterations we can make per second
33(benchmark-ips (sleep 2))
34</enscript>
35
36=== API
37
38<parameter>current-benchmark-iterations</parameter>
39The amount of iterations that are used in '''benchmark-run'''. This defaults to 100.
40
41<syntax>(benchmark-measure ?code)</syntax>
42Runs the '''?code''' once and returns the runtime in microseconds.
43
44<syntax>(benchmark-run [iterations] ?code)</syntax>
45Runs the '''?code''' '''iterations''' times and returns an alist with the following keys:
46
47* min - the minimum runtime of all iterations in microseconds
48* max - the maximum runtime of all iterations in microseconds
49* mean - the average runtime of all iterations in microseconds
50* standard-deviation - the sample standard deviation for the given runtimes
51
52If '''iterations''' is not given then '''curren-benchmark-iterations''' is used.
53
54<syntax>(benchmark-ips [seconds] ?code)</syntax>
55Determines how many times one can run the given '''?code''' per second and returns an alist with the following keys:
56
57* mean               - the mean amount iterations we can make per second
58* standard-deviation - the sample standard deviation for the given iterations
59
60If '''seconds''' is not given then it defaults to 5.
61
62=== License
63 This program is free software: you can redistribute it and/or modify
64 it under the terms of the GNU General Public License as published by
65 the Free Software Foundation, either version 3 of the License, or (at
66 your option) any later version.
67
68 This program is distributed in the hope that it will be useful, but
69 WITHOUT ANY WARRANTY; without even the implied warranty of
70 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
71 General Public License for more details.
72
73 A full copy of the GPL license can be found at
74 <http://www.gnu.org/licenses/>.
Note: See TracBrowser for help on using the repository browser.