Closed bsless closed 10 months ago
Thanks for the improvements! This ~only~ mainly effects (e.g. satifies?
) the case where the generator is not cached, right?
;; no cache
(mg/generate [:map [:x :int] [:y :int]])
;; instance cache
(let [s (m/schema [:map [:x :int] [:y :int]])]
(mg/generate s))
;; cached function
(let [g (mg/generator [:map [:x :int] [:y :int]])]
(mg/generate g))
On my machine, merging this. Thanks!!
(p/bench (mg/generate [:map [:x :int] [:y :int]]))
;; 18,5µs => 5,6 µs (-70%)
(let [s (m/schema [:map [:x :int] [:y :int]])]
(p/bench (mg/generate s)))
;; => 3.3µs => 2.8µs (-15%)
(let [g (mg/generator [:map [:x :int] [:y :int]])]
(p/bench (mg/generate g)))
;; => 2.8µs => 2.6µs (-8%)
Gladly :) For reference, this is the use case that made me care about construction performance https://github.com/bsless/fsm-test-check/blob/master/examples/add_delete_tx_malli.clj
This MR improves the performance for creating a map gen ~x5, mostly by removing a call to
satisfies?
, and further by choosing performant functions in the implementation.