-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfrugal-uuid-benchmark.lisp
69 lines (58 loc) · 2.27 KB
/
frugal-uuid-benchmark.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;;;; frugal-uuid-benchmark.lisp
(trivial-benchmark:define-benchmark-package #:frugal-uuid/benchmark
(:export #:run-benchmarks))
(in-package #:frugal-uuid/benchmark)
(define-benchmark gen-100k-v1-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-v1)))))
(when (fboundp 'fuuid:make-v3)
(define-benchmark gen-100k-v3-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-v3 fuuid:*ns-url*
"https://html5zombo.com/"))))))
(define-benchmark gen-100k-v4-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-v4)))))
(when (fboundp 'fuuid:make-v5)
(define-benchmark gen-100k-v5-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-v5 fuuid:*ns-url*
"https://html5zombo.com/"))))))
(define-benchmark gen-100k-v6-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-v6)))))
(define-benchmark gen-100k-v7-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-v7)))))
(when (fboundp 'fuuid:make-minara)
(define-benchmark gen-100k-minara-uuids ()
(declare (optimize speed))
(dotimes (_ 10)
(with-benchmark-sampling
(dotimes (_ 100000) (fuuid:make-minara))))))
(defun floatify-results (benchmark-results)
(loop :for v :being :each :hash-values :of benchmark-results
:using (hash-key k)
:do (setf (gethash k benchmark-results)
(loop :for metric :in v
:collect (loop :for n :in metric
:collect (typecase n
(ratio (float n))
(t n)))))
:finally (return benchmark-results)))
(defun run-benchmarks ()
(let ((results (run-package-benchmarks :package '#:frugal-uuid/benchmark
:verbose nil)))
(report (floatify-results results))))