Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU load from Java

Tags:

java

profiling

Is there a way to get the current cpu load under Java without using the JNI?

like image 291
paweloque Avatar asked Mar 11 '09 13:03

paweloque


People also ask

Why is Java taking up so much CPU?

Java applications may take high CPU resources for many reasons: Poorly designed application code with inefficient or infinite loops. Inefficient algorithms (poor application logic) Recursive method calls (causing hundreds of recursions)

How do you load a CPU?

Open Task Manager and go to the Performance tab to monitor the CPU load. Right click the CPU graph on the right and select "Change graph to -> Logical processors". Double click the loop. vbs script you created to execute it.


1 Answers

Use the ManagementFactory to get an OperatingSystemMXBean and call getSystemLoadAverage() on it.

like image 181
Joachim Sauer Avatar answered Oct 11 '22 12:10

Joachim Sauer