How can I measure the CPU time a Clojure function takes to execute?

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 (ie 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, eg Criterium.

链接地址: http://www.djcxy.com/p/51820.html

上一篇: 从PHPExcel的行和列索引中获取列的名称

下一篇: 我如何测量Clojure函数执行的CPU时间?