Skip to content

Instantly share code, notes, and snippets.

@chpill
Created March 26, 2017 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chpill/5ded6fbd8f214131cfae21d48c3b744b to your computer and use it in GitHub Desktop.
Save chpill/5ded6fbd8f214131cfae21d48c3b744b to your computer and use it in GitHub Desktop.
(defn using-xform--improved [chunks]
(transduce (comp (halt-when error?)
cat
(x/by-key :a x/count))
conj
{}
chunks))
(using-xform--improved chunks)
=> {0 3330, 1 3330, 2 3330} ;; Still works
(using-xform--improved mini-chunks-with-error)
=> {:error "Something terrible has happened!"} ;; Better!
(criterium/bench (using-xform--improved chunks))
"
Evaluation count : 156300 in 60 samples of 2605 calls.
Execution time mean : 405.974099 µs
Execution time std-deviation : 21.578325 µs
Execution time lower quantile : 377.589901 µs ( 2.5%)
Execution time upper quantile : 448.218002 µs (97.5%)
Overhead used : 1.481300 ns
Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
Variance from outliers : 38.5251 % Variance is moderately inflated by outliers
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment