-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbench.lisp
More file actions
23 lines (19 loc) · 794 Bytes
/
bench.lisp
File metadata and controls
23 lines (19 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;;;; Various microbenchmarks.
(defpackage maxpc.bench
(:use :cl :maxpc)
(:export :bench-=destructure
:bench-=destructure/bare))
(in-package :maxpc.bench)
(defun bench-=destructure (iterations)
(let ((input (make-array (truncate (* 2 iterations))
:element-type 'base-char
:initial-element #\x))
(parser (%any (?seq (=destructure (_ _)
(=list (=element) (=element)))))))
(time (parse input parser))))
(defun bench-=destructure/bare (iterations)
(let* ((p (lambda (input) (values input t t)))
(dp (=destructure (_ _) (=list p p)))
(input (maxpc.input:make-input "")))
(time (loop for i from 1 to (/ iterations 2) do
(funcall dp input)))))