Measuring Java execution time, memory usage and CPU load for a code segment
For a particular segment of Java code, I'd like to measure: Execution time (most likely thread execution time ) Memory usage CPU load (specifically attributable to the code segment) I'm a relative Java novice and am not familiar with how this might be achieved. I've been referred to JMX , however I'm not sure how that might be used, and JMX looks a bit 'heavy' for what I'm looking to do. Ideally I'd like some measurement class that can be told what I would like to measure, with the option of calling a start() method prior to a code segment and a stop() method after. Relevant metrics would be