Skip to content

Instantly share code, notes, and snippets.

@kindlychung kindlychung/sums.clj Secret
Last active Aug 29, 2015

Embed
What would you like to do?
(use 'criterium.core)
(defmacro bench-progress [& body]
`(with-progress-reporting
(bench ~@body)))
(defn sum [xs]
(reduce + xs))
(defn array-sum [^ints xs]
(loop [index 0 acc 0]
(if (< index (alength xs))
(recur (unchecked-inc index) (+ acc (aget xs index)))
acc)))
(let [x (range 1e6)
y (int-array x)]
(bench-progress (sum x))
(bench-progress (array-sum y)))
@kindlychung

This comment has been minimized.

Copy link
Owner Author

commented May 7, 2015

Evaluation count : 4860 in 60 samples of 81 calls.
             Execution time mean : 13.259991 ms
    Execution time std-deviation : 837.096383 µs
   Execution time lower quantile : 12.321027 ms ( 2.5%)
   Execution time upper quantile : 15.313246 ms (97.5%)
                   Overhead used : 1.820901 ns


Evaluation count : 4800 in 60 samples of 80 calls.
             Execution time mean : 13.274070 ms
    Execution time std-deviation : 716.595200 µs
   Execution time lower quantile : 12.294652 ms ( 2.5%)
   Execution time upper quantile : 14.822542 ms (97.5%)
                   Overhead used : 1.820901 ns
@kindlychung

This comment has been minimized.

Copy link
Owner Author

commented May 7, 2015

Warming up for JIT optimisations 10000000000 ...
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Evaluation count : 4500 in 60 samples of 75 calls.
Execution time mean : 13.578010 ms
Execution time std-deviation : 773.198360 µs
Execution time lower quantile : 12.405108 ms ( 2.5%)
Execution time upper quantile : 15.128228 ms (97.5%)
Overhead used : 1.820901 ns

Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
Variance from outliers : 41.8253 % Variance is moderately inflated by outliers
Warming up for JIT optimisations 10000000000 ...
compilation occured before 1454 iterations
compilation occured before 5813 iterations
compilation occured before 7266 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Evaluation count : 49260 in 60 samples of 821 calls.
Execution time mean : 1.244392 ms
Execution time std-deviation : 57.388621 µs
Execution time lower quantile : 1.183661 ms ( 2.5%)
Execution time upper quantile : 1.383249 ms (97.5%)
Overhead used : 1.820901 ns

Found 7 outliers in 60 samples (11.6667 %)
low-severe 5 (8.3333 %)
low-mild 2 (3.3333 %)
Variance from outliers : 31.9729 % Variance is moderately inflated by outliers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.