Skip to content

Commit 5f669d8

Browse files
committed
Added Brainfold benchmarks
1 parent 87e9831 commit 5f669d8

File tree

3 files changed

+61
-23
lines changed

3 files changed

+61
-23
lines changed

benchmarking/README.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1-
# To run Coalton Benchmarks:
1+
## To run the Coalton library Benchmarks:
22

33
`(ql:quickload :coalton/benchmarks)` or `(asdf:load-system :coalton/benchmarks)`
44

55
`(in-package #:coalton-benchmarks)`
66

77
`(run-coalton-benchmarks)`
88

9-
# Using Coalton Benchmarks
9+
# Using Coalton benchmarking
10+
11+
## Benchmark Settings
12+
13+
### Verbose
14+
Coalton benchmarking prints to the repl by default, though this setting can be turned off with:
15+
16+
```
17+
(cl:setf *coalton-verbose-benchmarking* cl:nil)
18+
```
19+
### Printing width
20+
This controls how wide the benchmark is printed to the repl, in characters. This can be changed using:
21+
```
22+
(cl:setf *coalton-benchmark-width* 90)
23+
```
24+
25+
### Print time in cientific notation
26+
By default, times are printed using scientific notation. This can be turned off using:
1027

1128
## Defining benchmarks:
1229

@@ -27,22 +44,7 @@ Benchmarks can be defined in any Coalton package:
2744
Unit)))
2845
```
2946

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-
```
4347

44-
### Print time in cientific notation
45-
By default, times are printed using scientific notation. This can be turned off using:
4648

4749
```
4850
(cl:setf *coalton-benchmark-sci-notation* cl:nil)
@@ -111,4 +113,4 @@ Package benchmarks can be reexported to other packages:
111113
"coalton-benchmarks/gabriel")
112114
```
113115

114-
This is useful unifying benchmarks at the top of package-per-file projects.
116+
This is especially useful for package-per-file projects.

examples/small-coalton-programs/small-coalton-programs.asd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(asdf:defsystem #:small-coalton-programs
2-
:depends-on (#:coalton)
2+
:depends-on (#:coalton #:coalton/benchmarking)
33
:pathname "src/"
44
:serial t
55
:components ((:file "package")

examples/small-coalton-programs/src/brainfold.lisp

+40-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
(cl:defpackage #:brainfold
1818
(:use
1919
#:coalton
20-
#:coalton-prelude)
20+
#:coalton-prelude
21+
#:coalton-benchmarking)
2122
(:local-nicknames
2223
(#:vec #:coalton-library/vector)
2324
(#:iter #:coalton-library/iterator)
@@ -31,12 +32,14 @@
3132
(:export
3233
#:eval
3334
#:run-program
34-
#:run-file
35-
35+
#:run-file)
36+
(:export
3637
;; Examples
3738
#:hello-world
3839
#:gnarly-hello-world
39-
#:squares))
40+
#:squares)
41+
(:export
42+
#:run-brainfold-benchmarks))
4043

4144
(in-package #:brainfold)
4245

@@ -305,3 +308,36 @@
305308

306309
(define (squares)
307310
(run-program "++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]")))
311+
312+
(define-benchmark bf-hello 1
313+
(fn ()
314+
(hello-world)
315+
Unit))
316+
317+
(define-benchmark bf-hello10 10
318+
(fn ()
319+
(hello-world)
320+
Unit))
321+
322+
(define-benchmark bf-gnarly 1
323+
(fn ()
324+
(gnarly-hello-world)
325+
Unit))
326+
327+
(define-benchmark bf-gnarly10 10
328+
(fn ()
329+
(gnarly-hello-world)
330+
Unit))
331+
332+
(define-benchmark squares 1
333+
(fn ()
334+
(squares)
335+
Unit))
336+
337+
(define-benchmark squares10 10
338+
(fn ()
339+
(squares)
340+
Unit))
341+
342+
(cl:defun run-brainfold-benchmarks ()
343+
(run-package-benchmarks "brainfold"))

0 commit comments

Comments
 (0)