Timing brings perf4j to clojure

Mon 02 July 2012
  • ANN tags:
  • clojure
  • github
  • java published: true comments: true

Timing is a dead simple clojure library wraps perf4j, while perf4j is an advanced library to log call time. It's like log4j to System.out.println, that to System.currentTimeMillies.

The core part of Timing library is a `timed` macro. You can put any forms in it and it will log the call time.

[cc lang="clojure"]
(timed "demo"
(look-for-something-from-the-moon)
...)
[/cc]

And it logs:
start[1341215254682] time[1000] tag[demo]

Timing looks up your classpath at startup for a logging backend: slf4j or log4j. If neither of them found, it fails back to log to stderr. By the way, log4j is the recommended logging backend. There are some predefined appender in perf4j to generate semi-realtime summary and charts. Anyway, Timing, as a library, doesn't depend on any library other than perf4j.

The project is hosted at github and available on clojars of version "0.1.0".