|
| 1 | +# To run Coalton Benchmarks: |
| 2 | + |
| 3 | +`(ql:quickload :coalton/benchmarks)` or `(asdf:load-system :coalton/benchmarks)` |
| 4 | + |
| 5 | +`(in-package #:coalton-benchmarks)` |
| 6 | + |
| 7 | +`(run-coalton-benchmarks)` |
| 8 | + |
| 9 | +# Using Coalton Benchmarks |
| 10 | + |
| 11 | +## Defining benchmarks: |
| 12 | + |
| 13 | +Benchmarks can be defined in any Coalton package: |
| 14 | + |
| 15 | +``` |
| 16 | +;; Defining a Coalton benchmark |
| 17 | +(define-benchmark stak 1000 ; iterations |
| 18 | + (fn () |
| 19 | + (stak 18 12 6) |
| 20 | + Unit)) |
| 21 | +
|
| 22 | +;; Defining a Lisp Benchmark |
| 23 | +(define-benchmark lisp-stak 1000 ; iterations |
| 24 | + (fn () |
| 25 | + (lisp Unit () |
| 26 | + (lisp-stak 18 12 6) |
| 27 | + Unit))) |
| 28 | +``` |
| 29 | + |
| 30 | +## Benchmark Settings |
| 31 | + |
| 32 | +### Verbose |
| 33 | +Coalton benchmarking prints to the repl by default, though this setting can be turned off with: |
| 34 | + |
| 35 | +``` |
| 36 | +(cl:setf *coalton-verbose-benchmarking* cl:nil) |
| 37 | +``` |
| 38 | +### Printing width |
| 39 | +This controls how wide the benchmark is printed to the repl, in characters. This can be changed using: |
| 40 | +``` |
| 41 | +(cl:setf *coalton-benchmark-width* 90) |
| 42 | +``` |
| 43 | + |
| 44 | +### Print time in cientific notation |
| 45 | +By default, times are printed using scientific notation. This can be turned off using: |
| 46 | + |
| 47 | +``` |
| 48 | +(cl:setf *coalton-benchmark-sci-notation* cl:nil) |
| 49 | +``` |
| 50 | + |
| 51 | +## Running individual benchmarks |
| 52 | + |
| 53 | +Individual benchmarks can be run with `#'run-benchmark`, as long as the benchmark is defined. |
| 54 | + |
| 55 | +`#'run-benchmark` returns a `BenchmarkResults` object. |
| 56 | + |
| 57 | +``` |
| 58 | +COALTON-BENCHMARKS> (coalton (run-benchmark "tak")) |
| 59 | +┌─────────────────────────────────────────────────────────────────────────────────────────┐ |
| 60 | +│ Benchmark tak │ |
| 61 | +├─────────────────────────────────────────────────────────────────────────────────────────┤ |
| 62 | +│ System: ARM64 OS-MACOSX SBCL2.2.4-WIP │ |
| 63 | +├─────────────────────────────────────────────────────────────────────────────────────────┤ |
| 64 | +│ Coalton development mode without heuristic inlining │ |
| 65 | +├───────────────────────┬─────────────────────┬─────────────────────┬─────────────────────┤ |
| 66 | +│ Benchmark │ Time Elapsed │ Bytes consed │ # Iterations │ |
| 67 | +├───────────────────────┼─────────────────────┼─────────────────────┼─────────────────────┤ |
| 68 | +│ TAK │ 9.4079e-1 s │ 0 │ 1000 │ |
| 69 | +└───────────────────────┴─────────────────────┴─────────────────────┴─────────────────────┘ |
| 70 | +
|
| 71 | +#.(BENCHMARKRESULTS "TAK" 1000 940788 #.(SOME 0)) |
| 72 | +``` |
| 73 | + |
| 74 | + |
| 75 | +## Running package benchmarks |
| 76 | + |
| 77 | +Package benchmarks can be run with #'run-package-benchmarks, from any package that imports coalton-benchmarking. |
| 78 | + |
| 79 | +`#'run-package-benchmarks` returns a `PackageBenchmarkResults` object. |
| 80 | + |
| 81 | +``` |
| 82 | +COALTON-BENCHMARKS> (coalton (run-package-benchmarks "coalton-benchmarks/gabriel/tak")) |
| 83 | +┌─────────────────────────────────────────────────────────────────────────────────────────┐ |
| 84 | +│ Package 'coalton-benchmarks/gabriel/tak' │ |
| 85 | +┌─────────────────────────────────────────────────────────────────────────────────────────┐ |
| 86 | +│ System: ARM64 OS-MACOSX SBCL2.2.4-WIP │ |
| 87 | +┌─────────────────────────────────────────────────────────────────────────────────────────┐ |
| 88 | +│ Coalton development mode without heuristic inlining │ |
| 89 | +├─────────────────┬─────────────────┬─────────────────┬─────────────────┬─────────────────┤ |
| 90 | +│ Benchmark │ Run time │ Real time │ Bytes consed │ # Iterations │ |
| 91 | +
|
| 92 | +├─────────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┤ |
| 93 | +│ TAK │ 1.043406 s │ 1.044723 s │ 65520 │ 1000 │ |
| 94 | +
|
| 95 | +├─────────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┤ |
| 96 | +│ LISP-TAK │ 0.082777 s │ 0.082867 s │ 65520 │ 1000 │ |
| 97 | +
|
| 98 | +└─────────────────┴─────────────────┴─────────────────┴─────────────────┴─────────────────┘ |
| 99 | +
|
| 100 | +#.(PACKAGEBENCHMARKRESULTS "coalton-benchmarks/gabriel/tak" #.(COALTON-BENCHMARKING/BENCHMARKING::BENCHMARKSYSTEM "ARM64" "OS-MACOSX" "SBCL" "2.2.4-WIP" COMMON-LISP:NIL COMMON-LISP:NIL) #(#.(BENCHMARKRESULTS "TAK" 1000 1040557 1041583 95888) |
| 101 | + #.(BENCHMARKRESULTS "LISP-TAK" 1000 83104 83040 65520))) |
| 102 | +``` |
| 103 | + |
| 104 | +## Reexporting package benchmarks |
| 105 | +Package benchmarks can be reexported to other packages: |
| 106 | + |
| 107 | +``` |
| 108 | +(reexport-benchmarks |
| 109 | + "coalton-benchmarks/fibonacci" |
| 110 | + "coalton-benchmarks/big-float" |
| 111 | + "coalton-benchmarks/gabriel") |
| 112 | +``` |
| 113 | + |
| 114 | +This is useful unifying benchmarks at the top of package-per-file projects. |
0 commit comments