Skip to content

benashford/extra-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

extra-time

A Clojure library designed to capture execution time in a more granular way than clojure.core's time, but less so than a proper profiling tool.

Usage

Obtainable from Clojars:

Clojars Project

To capture timing information for a block, wrap with with-times. This returns a tuple containing first the timing information, as a map, secondly the result of the block:

(let [[timings result] (with-times (do-stuff 1 2))]
  (println "Total time: " (:total timings))
  (do-something result))

To capture timing information, and print out a summary, wrap with report-times:

(report-times (do-stuff 1 2))

To capture more granular timings, in addition to the total time, use cap-time:

(report-times
  (doseq [x (range 1000)]
    (cap-time :inner (reduce + (range x)))))

This prints a summary that looks a bit like:

:inner  =>  {:count 1000, :average 0.07283200000000019, :sum 72.83200000000019}
:total  =>  (86.418)

The same block with with-times returns a Map that contains all the interim values, rather than the summary.

About

Like time, but more of it

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published