This repository has been archived by the owner on Dec 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmarks.clj
127 lines (97 loc) · 4.5 KB
/
benchmarks.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
(ns project.benchmarks
(:require [lazy-map.core :as lazy]
[strojure.zizzmap.core :as zizz]))
(set! *warn-on-reflection* true)
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
(def -core {:a 1})
(def -zizz (zizz/init {:a (identity 1)}))
(def -lazy (lazy/lazy-map {:a 1}))
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;;; Get existing value
(get -core :a)
; Execution time mean : 10,631153 ns
; Execution time std-deviation : 0,214500 ns
; Execution time lower quantile : 10,476636 ns ( 2,5%)
; Execution time upper quantile : 10,991837 ns (97,5%)
(get -zizz :a)
; Execution time mean : 10,826143 ns
; Execution time std-deviation : 0,107145 ns
; Execution time lower quantile : 10,680422 ns ( 2,5%)
; Execution time upper quantile : 10,946770 ns (97,5%)
(get -lazy :a)
; Execution time mean : 15,024707 ns
; Execution time std-deviation : 0,484878 ns
; Execution time lower quantile : 14,434105 ns ( 2,5%)
; Execution time upper quantile : 15,612451 ns (97,5%)
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;;; IFn existing value
(-core :a)
; Execution time mean : 6,564809 ns
; Execution time std-deviation : 0,170354 ns
; Execution time lower quantile : 6,376178 ns ( 2,5%)
; Execution time upper quantile : 6,745566 ns (97,5%)
(-zizz :a) ; 35% slower
; Execution time mean : 8,892992 ns
; Execution time std-deviation : 0,235938 ns
; Execution time lower quantile : 8,553368 ns ( 2,5%)
; Execution time upper quantile : 9,156227 ns (97,5%)
(comment
(-lazy :a))
;class lazy_map.core.LazyMap cannot be cast to class clojure.lang.IFn
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;;; Get missing value
(get -core :b)
; Execution time mean : 3,114547 ns
; Execution time std-deviation : 0,113178 ns
; Execution time lower quantile : 2,985051 ns ( 2,5%)
; Execution time upper quantile : 3,249071 ns (97,5%)
(get -zizz :b)
; Execution time mean : 4,316668 ns
; Execution time std-deviation : 0,110105 ns
; Execution time lower quantile : 4,165729 ns ( 2,5%)
; Execution time upper quantile : 4,413324 ns (97,5%)
(get -lazy :b)
; Execution time mean : 7,664370 ns
; Execution time std-deviation : 0,245763 ns
; Execution time lower quantile : 7,327563 ns ( 2,5%)
; Execution time upper quantile : 7,901659 ns (97,5%)
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;;; Initialization cost
{:a 1}
; Execution time mean : 3,340801 ns
; Execution time std-deviation : 0,165079 ns
; Execution time lower quantile : 3,166035 ns ( 2,5%)
; Execution time upper quantile : 3,541582 ns (97,5%)
(zizz/init {:a 1})
; Execution time mean : 7,241391 ns
; Execution time std-deviation : 1,001237 ns
; Execution time lower quantile : 6,549447 ns ( 2,5%)
; Execution time upper quantile : 8,946173 ns (97,5%)
(zizz/init {:a (identity 1)})
; Execution time mean : 40,740169 ns
; Execution time std-deviation : 5,418957 ns
; Execution time lower quantile : 36,433236 ns ( 2,5%)
; Execution time upper quantile : 46,921194 ns (97,5%)
(lazy/lazy-map {:a 1})
; Execution time mean : 37,309820 ns
; Execution time std-deviation : 4,009381 ns
; Execution time lower quantile : 33,804579 ns ( 2,5%)
; Execution time upper quantile : 42,172047 ns (97,5%)
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;;; assoc
(assoc -core :b 2)
; Execution time mean : 45,786820 ns
; Execution time std-deviation : 0,876607 ns
; Execution time lower quantile : 44,592850 ns ( 2,5%)
; Execution time upper quantile : 46,794216 ns (97,5%)
(assoc -zizz :b 2)
; Execution time mean : 48,847897 ns
; Execution time std-deviation : 1,644363 ns
; Execution time lower quantile : 47,081225 ns ( 2,5%)
; Execution time upper quantile : 50,683465 ns (97,5%)
(assoc -lazy :b 2)
; Execution time mean : 49,034480 ns
; Execution time std-deviation : 3,042376 ns
; Execution time lower quantile : 46,031159 ns ( 2,5%)
; Execution time upper quantile : 53,893994 ns (97,5%)
;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,