Skip to content

Commit cd778ad

Browse files
committed
Rerun tests with bench (up to +40% perf)
1 parent 2077c14 commit cd778ad

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

test/compojure/api/perf_test.clj

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@
66
[schema.core :as s]))
77

88
;;
9-
;; start repl with `lein perf repl`. note, all numbers are from Tommi's
10-
;; laptop.
9+
;; start repl with `lein perf repl`
10+
;; perf measured with the following setup:
11+
;;
12+
;; Model Name: MacBook Pro
13+
;; Model Identifier: MacBookPro11,3
14+
;; Processor Name: Intel Core i7
15+
;; Processor Speed: 2,5 GHz
16+
;; Number of Processors: 1
17+
;; Total Number of Cores: 4
18+
;; L2 Cache (per Core): 256 KB
19+
;; L3 Cache: 6 MB
20+
;; Memory: 16 GB
1121
;;
1222

1323
(defn title [s]
@@ -23,11 +33,12 @@
2333
(s/optional-key :description) s/Str
2434
:address (s/maybe {:street s/Str
2535
:country (s/enum "FI" "PO")})
26-
:orders [{:name s/Str
36+
:orders [{:name #"^k"
2737
:price s/Any
2838
:shipping s/Bool}]})
2939

30-
(defn c-api-bench []
40+
(defn bench []
41+
3142

3243
(let [app (api
3344
(GET* "/30" []
@@ -37,9 +48,9 @@
3748
(title "GET JSON")
3849

3950
(assert (= {:result 30} (second (call))))
40-
(cc/quick-bench (call)))
51+
(cc/bench (call)))
4152

42-
; 32µs => 30µs (-6%)
53+
; 26µs => 26µs (-0%)
4354

4455
(let [app (api
4556
(POST* "/plus" []
@@ -52,9 +63,9 @@
5263
(title "JSON POST with 2-way coercion")
5364

5465
(assert (= {:result 30} (second (call))))
55-
(cc/quick-bench (call)))
66+
(cc/bench (call)))
5667

57-
;; 104µs => 73µs (-30%)
68+
;; 87µs => 65µs (-25%)
5869

5970
(let [app (api
6071
(context* "/a" []
@@ -70,9 +81,9 @@
7081
(title "JSON POST with 2-way coercion + contexts")
7182

7283
(assert (= {:result 30} (second (call))))
73-
(cc/quick-bench (call)))
84+
(cc/bench (call)))
7485

75-
;; 113µs => 80µs (-30%)
86+
;; 102µs => 78µs (-24%)
7687

7788
(let [app (api
7889
(POST* "/echo" []
@@ -95,11 +106,11 @@
95106
(title "JSON POST with nested data")
96107

97108
(s/check Order (second (call)))
98-
(cc/quick-bench (call)))
109+
(cc/bench (call)))
99110

100-
;; 343µs => 175µs (-49%)
111+
;; 311µs => 194µs (-38%)
101112

102113
)
103114

104115
(comment
105-
(c-api-bench))
116+
(bench))

0 commit comments

Comments
 (0)