Skip to content

Commit

Permalink
Added Brainfold benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Izaakwltn committed Oct 17, 2024
1 parent 87e9831 commit 5f669d8
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
38 changes: 20 additions & 18 deletions benchmarking/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# To run Coalton Benchmarks:
## To run the Coalton library Benchmarks:

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

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

`(run-coalton-benchmarks)`

# Using Coalton Benchmarks
# Using Coalton benchmarking

## Benchmark Settings

### Verbose
Coalton benchmarking prints to the repl by default, though this setting can be turned off with:

```
(cl:setf *coalton-verbose-benchmarking* cl:nil)
```
### Printing width
This controls how wide the benchmark is printed to the repl, in characters. This can be changed using:
```
(cl:setf *coalton-benchmark-width* 90)
```

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

## Defining benchmarks:

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

## Benchmark Settings

### Verbose
Coalton benchmarking prints to the repl by default, though this setting can be turned off with:

```
(cl:setf *coalton-verbose-benchmarking* cl:nil)
```
### Printing width
This controls how wide the benchmark is printed to the repl, in characters. This can be changed using:
```
(cl:setf *coalton-benchmark-width* 90)
```

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

```
(cl:setf *coalton-benchmark-sci-notation* cl:nil)
Expand Down Expand Up @@ -111,4 +113,4 @@ Package benchmarks can be reexported to other packages:
"coalton-benchmarks/gabriel")
```

This is useful unifying benchmarks at the top of package-per-file projects.
This is especially useful for package-per-file projects.
2 changes: 1 addition & 1 deletion examples/small-coalton-programs/small-coalton-programs.asd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(asdf:defsystem #:small-coalton-programs
:depends-on (#:coalton)
:depends-on (#:coalton #:coalton/benchmarking)
:pathname "src/"
:serial t
:components ((:file "package")
Expand Down
44 changes: 40 additions & 4 deletions examples/small-coalton-programs/src/brainfold.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
(cl:defpackage #:brainfold
(:use
#:coalton
#:coalton-prelude)
#:coalton-prelude
#:coalton-benchmarking)
(:local-nicknames
(#:vec #:coalton-library/vector)
(#:iter #:coalton-library/iterator)
Expand All @@ -31,12 +32,14 @@
(:export
#:eval
#:run-program
#:run-file

#:run-file)
(:export
;; Examples
#:hello-world
#:gnarly-hello-world
#:squares))
#:squares)
(:export
#:run-brainfold-benchmarks))

(in-package #:brainfold)

Expand Down Expand Up @@ -305,3 +308,36 @@

(define (squares)
(run-program "++++[>+++++<-]>[<+++++>-]+<+[>[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+>>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<]<<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]")))

(define-benchmark bf-hello 1
(fn ()
(hello-world)
Unit))

(define-benchmark bf-hello10 10
(fn ()
(hello-world)
Unit))

(define-benchmark bf-gnarly 1
(fn ()
(gnarly-hello-world)
Unit))

(define-benchmark bf-gnarly10 10
(fn ()
(gnarly-hello-world)
Unit))

(define-benchmark squares 1
(fn ()
(squares)
Unit))

(define-benchmark squares10 10
(fn ()
(squares)
Unit))

(cl:defun run-brainfold-benchmarks ()
(run-package-benchmarks "brainfold"))

0 comments on commit 5f669d8

Please sign in to comment.