I know I can get the time take to evaluate a function can be printed out on the screen/stdout using the time function/macro.
The time macro returns the value of the evaluated function, which makes it great to use it inline. However I want to automatically measure the runtime under specific circumstances.
Is there a function which returns the elapsed time in some library to help with this benchmarking?
If you generate a Java binding for your functions (and with some Clojure Maven plugin reconfiguration), you can even use JMH (http://openjdk.java.net/projects/code-tools/jmh/) which is probably the best JVM microbenchmarking harness. Have a look at https://github.com/circlespainter/pulsar-auto-instrument-bench
You might want to look into Hugo Duncan's benchmarking library for Clojure -- Criterium.
From the README:
If it's just a matter of wanting to capture the string programmatically, you can bind *out* to something else before using time.
If you want more control over the format, then you can create your own version of time using Java's System time methods, which is what the time macro uses under the hood anyway:
Take that basic structure and replace the call to prn with whatever reporting mechanism you would prefer.