Skip to content

Instantly share code, notes, and snippets.

@noprompt
Created December 15, 2018 05:54
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 noprompt/9f373fef5b070ee977f28b9daf2fc6ef to your computer and use it in GitHub Desktop.
Save noprompt/9f373fef5b070ee977f28b9daf2fc6ef to your computer and use it in GitHub Desktop.
(ns if-not.bench
(:require [criterium.core]))
(defmacro if-not*
([test then] `(if ~test nil ~then))
([test then else]
`(if ~test ~else ~then)))
(criterium.core/bench (if-not false 1 2))
;; Evaluation count : 5375474880 in 60 samples of 89591248 calls.
;; Execution time mean : 4.828435 ns
;; Execution time std-deviation : 0.372316 ns
;; Execution time lower quantile : 4.058421 ns ( 2.5%)
;; Execution time upper quantile : 5.429294 ns (97.5%)
;; Overhead used : 7.932535 ns
;; Found 5 outliers in 60 samples (8.3333 %)
;; low-severe 4 (6.6667 %)
;; low-mild 1 (1.6667 %)
;; Variance from outliers : 56.8430 % Variance is severely inflated by outliers
(criterium.core/bench (if-not* false 1 2))
;; Evaluation count : 4689823380 in 60 samples of 78163723 calls.
;; Execution time mean : 3.324962 ns
;; Execution time std-deviation : 0.587737 ns
;; Execution time lower quantile : 2.372741 ns ( 2.5%)
;; Execution time upper quantile : 4.521725 ns (97.5%)
;; Overhead used : 7.932535 ns
;; Found 1 outliers in 60 samples (1.6667 %)
;; low-severe 1 (1.6667 %)
;; Variance from outliers : 87.6830 % Variance is severely inflated by outliers
(criterium.core/bench (if-not nil 1 2))
;; Evaluation count : 4511376060 in 60 samples of 75189601 calls.
;; Execution time mean : 3.811856 ns
;; Execution time std-deviation : 0.235907 ns
;; Execution time lower quantile : 3.628282 ns ( 2.5%)
;; Execution time upper quantile : 4.291959 ns (97.5%)
;; Overhead used : 7.932535 ns
;; Found 4 outliers in 60 samples (6.6667 %)
;; low-severe 3 (5.0000 %)
;; low-mild 1 (1.6667 %)
;; Variance from outliers : 46.7450 % Variance is moderately inflated by outliers
(criterium.core/bench (if-not* nil 1 2))
;; Evaluation count : 5057628360 in 60 samples of 84293806 calls.
;; Execution time mean : 2.846601 ns
;; Execution time std-deviation : 0.704062 ns
;; Execution time lower quantile : 2.392742 ns ( 2.5%)
;; Execution time upper quantile : 5.207902 ns (97.5%)
;; Overhead used : 7.932535 ns
;; Found 10 outliers in 60 samples (16.6667 %)
;; low-severe 2 (3.3333 %)
;; low-mild 8 (13.3333 %)
;; Variance from outliers : 94.6158 % Variance is severely inflated by outliers
(criterium.core/bench (if-not true 1 2))
;; Evaluation count : 4470344280 in 60 samples of 74505738 calls.
;; Execution time mean : 3.555208 ns
;; Execution time std-deviation : 0.270488 ns
;; Execution time lower quantile : 2.841357 ns ( 2.5%)
;; Execution time upper quantile : 3.990131 ns (97.5%)
;; Overhead used : 7.932535 ns
;; Found 17 outliers in 60 samples (28.3333 %)
;; low-severe 11 (18.3333 %)
;; low-mild 1 (1.6667 %)
;; high-mild 5 (8.3333 %)
;; Variance from outliers : 56.8025 % Variance is severely inflated by outliers
(criterium.core/bench (if-not* true 1 2))
;; Evaluation count : 5094687420 in 60 samples of 84911457 calls.
;; Execution time mean : 2.923711 ns
;; Execution time std-deviation : 0.580214 ns
;; Execution time lower quantile : 2.176261 ns ( 2.5%)
;; Execution time upper quantile : 4.110925 ns (97.5%)
;; Overhead used : 7.932535 ns
;; Found 1 outliers in 60 samples (1.6667 %)
;; low-severe 1 (1.6667 %)
;; Variance from outliers : 91.1110 % Variance is severely inflated by outliers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment