Skip to content

Instantly share code, notes, and snippets.

@jebberjeb
Last active December 21, 2015 11:58
Show Gist options
  • Save jebberjeb/6302301 to your computer and use it in GitHub Desktop.
Save jebberjeb/6302301 to your computer and use it in GitHub Desktop.
Profile partial, fn, #()
(ns timbre-test.core
(:require [taoensso.timbre.profiling :as profiling :refer (p profile)]))
;; Profile partial vs #/fn
(let [padd (partial + 5)
fadd (fn [n] (+ 5 n))
aadd #(+ % 5)]
(defn add-them-all [num]
(p :partial (padd num))
(p :fn (fadd num))
(p :anon (aadd num))))
(profile :info :Arithmetic (dotimes [n 100000] (add-them-all n)))
;;; Calls Min Max MAD Mean Time% Time
;;; p 100000 27ns 5ms 617ns 1μs 18 109ms
;;; f 100000 27ns 5ms 417ns 346ns 6 35ms
;;; # 100000 27ns 483μs 216ns 262ns 4 26ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment