long start = System.currentTimeMillis();
test1();
long end = System.currentTimeMillis();
long duration1 = end - start;
But there is a better way to do this . you can useThreadMXBean.getCurrentThreadCpuTime()
ThreadMXBean mx = ManagementFactory.getThreadMXBean();
function in jdk.
you can use
long start = mx.getCurrentThreadCpuTime();
test1();
long end = mx.getCurrentThreadCpuTime();
long duration1 = end - start;
java documentation here
17.7.08
java performance
Java programmers often write the code to test the performance of the certain classes , normally we wrote code like this
Subscribe to:
Post Comments (Atom)
0 opinions:
Post a Comment