Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing arity vs map function call speed in clojure
(defn add [x y] (+ x y))=> #'user/add(defn addm [{x :x y :y}] (+ x y))=> #'user/addm(reduce (fn [r i] (addm {:x r :y i})) 0 (range 128))=> 8128(quick-bench (reduce (fn [r i] (add r i)) 0 (range 128)))Evaluation count : 270720 in 6 samples of 45120 calls. Execution time mean : 2.212768 µs Execution time std-deviation : 76.515990 ns Execution time lower quantile : 2.130557 µs ( 2.5%) Execution time upper quantile : 2.336060 µs (97.5%) Overhead used : 1.902301 nsFound 1 outliers in 6 samples (16.6667 %) low-severe 1 (16.6667 %) Variance from outliers : 13.8889 % Variance is moderately inflated by outliers=> nil(quick-bench (reduce (fn [r i] (add r i)) 0 (range 128)))Evaluation count : 265158 in 6 samples of 44193 calls. Execution time mean : 2.323233 µs Execution time std-deviation : 176.530052 ns Execution time lower quantile : 2.223932 µs ( 2.5%) Execution time upper quantile : 2.626066 µs (97.5%) Overhead used : 1.902301 nsFound 1 outliers in 6 samples (16.6667 %) low-severe 1 (16.6667 %) Variance from outliers : 15.4138 % Variance is moderately inflated by outliers=> nil(quick-bench (reduce (fn [r i] (addm {:x r :y i})) 0 (range 128)))Evaluation count : 56208 in 6 samples of 9368 calls. Execution time mean : 11.928436 µs Execution time std-deviation : 950.653954 ns Execution time lower quantile : 10.705623 µs ( 2.5%) Execution time upper quantile : 13.069694 µs (97.5%) Overhead used : 1.902301 ns
@Hendekagon

This comment has been minimized.

Copy link
Owner Author

Hendekagon commented Mar 4, 2018

(defn add [x y] (+ x y))
=> #'user/add
(defn addm [{x :x y :y}] (+ x y))
=> #'user/addm
(quick-bench (reduce (fn [r i] (add r i)) 0 (range 128)))
Evaluation count : 270720 in 6 samples of 45120 calls.
             Execution time mean : 2.212768 µs
    Execution time std-deviation : 76.515990 ns
   Execution time lower quantile : 2.130557 µs ( 2.5%)
   Execution time upper quantile : 2.336060 µs (97.5%)
                   Overhead used : 1.902301 ns

Found 1 outliers in 6 samples (16.6667 %)
	low-severe	 1 (16.6667 %)
 Variance from outliers : 13.8889 % Variance is moderately inflated by outliers
=> nil
(quick-bench (reduce (fn [r i] (add r i)) 0 (range 128)))
Evaluation count : 265158 in 6 samples of 44193 calls.
             Execution time mean : 2.323233 µs
    Execution time std-deviation : 176.530052 ns
   Execution time lower quantile : 2.223932 µs ( 2.5%)
   Execution time upper quantile : 2.626066 µs (97.5%)
                   Overhead used : 1.902301 ns

Found 1 outliers in 6 samples (16.6667 %)
	low-severe	 1 (16.6667 %)
 Variance from outliers : 15.4138 % Variance is moderately inflated by outliers
=> nil
(quick-bench (reduce (fn [r i] (addm {:x r :y i})) 0 (range 128)))
Evaluation count : 56208 in 6 samples of 9368 calls.
             Execution time mean : 11.928436 µs
    Execution time std-deviation : 950.653954 ns
   Execution time lower quantile : 10.705623 µs ( 2.5%)
   Execution time upper quantile : 13.069694 µs (97.5%)
                   Overhead used : 1.902301 ns
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.