I have a variant of the timings macro that I used to profile some numeric 
code recently.  You sprinkle it in your code, and it aggregates timings 
during a run by keywords of your choice.:


(def ^:dynamic *times* nil)

(defmacro timek
  "Evaluates expr and prints the time it took.  Returns the value of
 expr."
  {:added "1.0"}
  [k expr]
  (let [plus (fn [val val2] (if val (+ val val2) val2))]
    `(let [start# (. System (nanoTime))
           ret# ~expr
           t# (/ (double (- (. System (nanoTime)) start#)) 1000000.0)]
       (swap! *times* update-in [~k] ~plus t#)
       ret#)))

(defmacro with-timek
  [& body]
  `(binding [*times* (atom {})]
     ~@body
     (clojure.pprint/pprint @*times*)))




On Wednesday, July 17, 2013 6:03:50 PM UTC-4, Marc Dzaebel wrote:
>
> Frantisek,
>
> your timings macro is really helpful and you already have many interesting 
> examples in the code. So I combine yours, mine and Alex recommendations as:
>
> - Programmatic creation of tests/docs to adapt to current Clojure versions
> - Systematically organized/grouped/sorted samples
> - Comments on causation
> - Using benchmarking libraries to increase quality
> - Nice, compact, tabular presentation with source, ratio, percentage etc.
> - My: Prioritize over all cases according to frequency * impact
> - My: Short description of the example
>
> Hope to have time to contribute to such a list, may be in the clojure wiki.
>
> Marc
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to