Quantcast
Channel: Java
Viewing all articles
Browse latest Browse all 10

Java tip: How to get CPU, system, and user time for benchmarking

$
0
0

Performance optimization requires that you measure the time to perform a task, then try algorithm and coding changes to make the task faster. Prior to Java 5, the only way to time a task was to measure wall clock time. Unfortunately, this gives inaccurate results when there is other activity on the system (and there always is). Java 5 introduced the java.lang.management package and methods to report CPU and user time per thread. These times are not affected by other system activity, making them just what we need for benchmarking. This article shows how to use the java.lang.management package to benchmark your application.

read more


Viewing all articles
Browse latest Browse all 10

Trending Articles