I have seen profiling macros for Clojure but they all seem to use elapsed time. Is there any way to get the CPU time taken?
Not seen such a solution.
However, you can probably achieve it with the java.lang.management Java package which supports management / monitoring of the JVM.
In particular, the ThreadMXBean.getCurrentThreadCPUTime() sounds like it would do what you want.
Normally however I would just try and run my benchmark in an uncontested environment (i.e. one where it can get 100% CPU) and make the simplyfying assumption that elapsed time is approximately equal to CPU time. Then you can use the usual Clojure benchmarking tools, e.g. Criterium.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With