-
-
Save luxbock/29092fd7357b3932eddfa7ee0df98d46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn round-frequencies | |
[iso-map find-size round-fn filter-fn] | |
(transform [MAP-VALS | |
(transformed | |
[ALL (view find-size)] | |
round-fn) | |
(view (partial filter filter-fn)) | |
(view frequencies) | |
(transformed | |
[(subselect MAP-VALS) | |
(collect-one (view #(apply + %))) | |
ALL] | |
revdiv)] | |
#(into (sorted-map) | |
(keep (fn [[k v]] | |
(when (> v 1/100) | |
[k (* 100 v)]))) | |
%) | |
iso-map)) | |
user> (>bench (round-frequencies ttt iso-size round-by-quarter #(< % 7))) | |
;; Evaluation count : 600 in 60 samples of 10 calls. | |
;; Execution time mean : 114.857931 ms | |
;; Execution time std-deviation : 9.906417 ms | |
;; Execution time lower quantile : 106.664295 ms ( 2.5%) | |
;; Execution time upper quantile : 141.814355 ms (97.5%) | |
;; Overhead used : 1.706331 ns | |
;; | |
;; Found 3 outliers in 60 samples (5.0000 %) | |
;; low-severe 3 (5.0000 %) | |
;; Variance from outliers : 63.5209 % Variance is severely inflated by outliers | |
(defn round-freqs | |
[iso-map find-size round-fn filter-fn] | |
(into {} | |
(map (fn [[k v]] | |
[k (let [freqs | |
(frequencies | |
(sequence | |
(comp | |
(map find-size) | |
(map round-fn) | |
(filter filter-fn)) | |
v))] | |
(into (sorted-map) | |
(keep (fn [[k v]] | |
(let [v* (/ v (apply + (vals freqs)))] | |
(when (> v* 1/100) | |
[k (* 100 v*)])))) | |
freqs))])) | |
iso-map)) | |
user> (>bench (round-freqs ttt iso-size round-by-quarter #(< % 7))) | |
;; Evaluation count : 600 in 60 samples of 10 calls. | |
;; Execution time mean : 110.932326 ms | |
;; Execution time std-deviation : 13.419260 ms | |
;; Execution time lower quantile : 101.828423 ms ( 2.5%) | |
;; Execution time upper quantile : 137.104938 ms (97.5%) | |
;; Overhead used : 1.706331 ns | |
;; | |
;; Found 2 outliers in 60 samples (3.3333 %) | |
;; low-severe 1 (1.6667 %) | |
;; low-mild 1 (1.6667 %) | |
;; Variance from outliers : 77.2413 % Variance is severely inflated by outliers | |
(defn round-fqs | |
[iso-map find-size round-fn filter-fn] | |
(transform MAP-VALS | |
#(let [freqs (frequencies | |
(sequence | |
(comp | |
(map find-size) | |
(filter filter-fn) | |
(map round-fn)) | |
%)) | |
sum (apply + (vals freqs))] | |
(into (sorted-map) | |
(keep (fn [[k v]] | |
(let [v* (/ v sum)] | |
(when (> v* 1/100) | |
[k (* 100 v*)])))) | |
freqs)) | |
iso-map)) | |
user> (>bench (round-fqs ttt iso-size round-by-quarter #(< % 7))) | |
;; Evaluation count : 600 in 60 samples of 10 calls. | |
;; Execution time mean : 103.850705 ms | |
;; Execution time std-deviation : 2.996364 ms | |
;; Execution time lower quantile : 100.685825 ms ( 2.5%) | |
;; Execution time upper quantile : 112.062956 ms (97.5%) | |
;; Overhead used : 1.706331 ns | |
;; | |
;; Found 3 outliers in 60 samples (5.0000 %) | |
;; low-severe 3 (5.0000 %) | |
;; Variance from outliers : 15.7977 % Variance is moderately inflated by outliers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment