-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf.clj
137 lines (107 loc) · 4.5 KB
/
perf.clj
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
(ns perf
(:require
[criterium.core :as bench]
[tenet.response :as r]
[tenet.response.http :as http]))
;; MacBook Pro (15-inch, 2018/2019)
;; Intel(R) Core(TM) i7-8850H (12) @ 2.60 GHz
;; 16.00 GiB
;; macOS Sequoia 15.0.1 x86_64
;;;;
;; Defaults
;;;;
(bench/quick-bench
(r/error? ::r/error)) ; => true
; (out) Evaluation count : 20083626 in 6 samples of 3347271 calls.
; (out) Execution time mean : 14.875154 ns
; (out) Execution time std-deviation : 0.147461 ns
; (out) Execution time lower quantile : 14.692583 ns ( 2.5%)
; (out) Execution time upper quantile : 15.040448 ns (97.5%)
; (out) Overhead used : 15.049260 ns
(bench/quick-bench
(r/error? ::not-error)) ; => false
; (out) Evaluation count : 19714662 in 6 samples of 3285777 calls.
; (out) Execution time mean : 15.423519 ns
; (out) Execution time std-deviation : 0.092422 ns
; (out) Execution time lower quantile : 15.261812 ns ( 2.5%)
; (out) Execution time upper quantile : 15.515286 ns (97.5%)
; (out) Overhead used : 15.049260 ns
;;;;
;; Java objects
;;;;
(bench/quick-bench
(r/kind 42)) ; => nil
; (out) Evaluation count : 46984380 in 6 samples of 7830730 calls.
; (out) Execution time mean : 0.432813 ns
; (out) Execution time std-deviation : 0.038412 ns
; (out) Execution time lower quantile : 0.391860 ns ( 2.5%)
; (out) Execution time upper quantile : 0.470783 ns (97.5%)
; (out) Overhead used : 12.341496 ns
;;;;
;; Vector
;;;;
(def user-exists
[:user/exists {:user/id 42}])
(bench/quick-bench
(r/kind user-exists)) ; => :user/exists
; (out) Evaluation count : 31009008 in 6 samples of 5168168 calls.
; (out) Execution time mean : 4.626609 ns
; (out) Execution time std-deviation : 0.274217 ns
; (out) Execution time lower quantile : 4.281799 ns ( 2.5%)
; (out) Execution time upper quantile : 4.951825 ns (97.5%)
; (out) Overhead used : 15.041038 ns
(r/derive :user/exists) ; => :user/exists
(bench/quick-bench
(r/error? user-exists)) ; => true
; (out) Evaluation count : 14381382 in 6 samples of 2396897 calls.
; (out) Execution time mean : 26.636206 ns
; (out) Execution time std-deviation : 0.239904 ns
; (out) Execution time lower quantile : 26.394512 ns ( 2.5%)
; (out) Execution time upper quantile : 26.934575 ns (97.5%)
; (out) Overhead used : 15.050630 ns
(r/underive :user/exists) ; => :user/exists
;;;;
;; Builders
;;;;
(bench/quick-bench
(r/as ::error 42)) ; => [:perf/error 42]
; (out) Evaluation count : 28434054 in 6 samples of 4739009 calls.
; (out) Execution time mean : 13.717179 ns
; (out) Execution time std-deviation : 10.464559 ns
; (out) Execution time lower quantile : 6.355319 ns ( 2.5%)
; (out) Execution time upper quantile : 28.825937 ns (97.5%)
; (out) Overhead used : 15.041038 ns
(bench/quick-bench
(r/as ::error user-exists)) ; => [:perf/error {:user/id 42}]
; eval (root-form): (bench/quick-bench (r/as ::error user-exists))
; (out) Evaluation count : 14432754 in 6 samples of 2405459 calls.
; (out) Execution time mean : 27.933007 ns
; (out) Execution time std-deviation : 1.615869 ns
; (out) Execution time lower quantile : 26.703075 ns ( 2.5%)
; (out) Execution time upper quantile : 30.424757 ns (97.5%)
; (out) Overhead used : 15.048625 ns
;;;;
;; Http
;;;;
(r/derive :user/exists) ; => :user/exists
(http/derive :user/exists ::http/conflict) ;; :user/exists
(r/error? user-exists) ; => true
(bench/quick-bench
(http/status user-exists)) ; => 409
; (out) Evaluation count : 12864336 in 6 samples of 2144056 calls.
; (out) Execution time mean : 34.513275 ns
; (out) Execution time std-deviation : 0.259090 ns
; (out) Execution time lower quantile : 34.107100 ns ( 2.5%)
; (out) Execution time upper quantile : 34.782836 ns (97.5%)
; (out) Overhead used : 12.343262 ns
(r/underive :user/exists) ; => :user/exists
(http/underive :user/exists) ; => :user/exists
(r/error? user-exists) ; => false
(bench/quick-bench
(http/status user-exists)) ; => 200
; (out) Evaluation count : 21069486 in 6 samples of 3511581 calls.
; (out) Execution time mean : 16.189475 ns
; (out) Execution time std-deviation : 0.041101 ns
; (out) Execution time lower quantile : 16.130563 ns ( 2.5%)
; (out) Execution time upper quantile : 16.233606 ns (97.5%)
; (out) Overhead used : 12.343262 ns