|
6 | 6 | [schema.core :as s])) |
7 | 7 |
|
8 | 8 | ;; |
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 |
11 | 21 | ;; |
12 | 22 |
|
13 | 23 | (defn title [s] |
|
23 | 33 | (s/optional-key :description) s/Str |
24 | 34 | :address (s/maybe {:street s/Str |
25 | 35 | :country (s/enum "FI" "PO")}) |
26 | | - :orders [{:name s/Str |
| 36 | + :orders [{:name #"^k" |
27 | 37 | :price s/Any |
28 | 38 | :shipping s/Bool}]}) |
29 | 39 |
|
30 | | -(defn c-api-bench [] |
| 40 | +(defn bench [] |
| 41 | + |
31 | 42 |
|
32 | 43 | (let [app (api |
33 | 44 | (GET* "/30" [] |
|
37 | 48 | (title "GET JSON") |
38 | 49 |
|
39 | 50 | (assert (= {:result 30} (second (call)))) |
40 | | - (cc/quick-bench (call))) |
| 51 | + (cc/bench (call))) |
41 | 52 |
|
42 | | - ; 32µs => 30µs (-6%) |
| 53 | + ; 26µs => 26µs (-0%) |
43 | 54 |
|
44 | 55 | (let [app (api |
45 | 56 | (POST* "/plus" [] |
|
52 | 63 | (title "JSON POST with 2-way coercion") |
53 | 64 |
|
54 | 65 | (assert (= {:result 30} (second (call)))) |
55 | | - (cc/quick-bench (call))) |
| 66 | + (cc/bench (call))) |
56 | 67 |
|
57 | | - ;; 104µs => 73µs (-30%) |
| 68 | + ;; 87µs => 65µs (-25%) |
58 | 69 |
|
59 | 70 | (let [app (api |
60 | 71 | (context* "/a" [] |
|
70 | 81 | (title "JSON POST with 2-way coercion + contexts") |
71 | 82 |
|
72 | 83 | (assert (= {:result 30} (second (call)))) |
73 | | - (cc/quick-bench (call))) |
| 84 | + (cc/bench (call))) |
74 | 85 |
|
75 | | - ;; 113µs => 80µs (-30%) |
| 86 | + ;; 102µs => 78µs (-24%) |
76 | 87 |
|
77 | 88 | (let [app (api |
78 | 89 | (POST* "/echo" [] |
|
95 | 106 | (title "JSON POST with nested data") |
96 | 107 |
|
97 | 108 | (s/check Order (second (call))) |
98 | | - (cc/quick-bench (call))) |
| 109 | + (cc/bench (call))) |
99 | 110 |
|
100 | | - ;; 343µs => 175µs (-49%) |
| 111 | + ;; 311µs => 194µs (-38%) |
101 | 112 |
|
102 | 113 | ) |
103 | 114 |
|
104 | 115 | (comment |
105 | | - (c-api-bench)) |
| 116 | + (bench)) |
0 commit comments