Add getSystemLoad method

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2024-06-10 19:46:40 +07:00
parent d51d03e0fa
commit c573672fce
No known key found for this signature in database
GPG key ID: 02AA2BAE387C8307

View file

@ -30,12 +30,16 @@ public class Profiler {
}
public static void printSystemLoad() {
log.info(getSystemLoad());
}
public static String getSystemLoad() {
Runtime runtime = Runtime.getRuntime();
long free = runtime.freeMemory();
long total = runtime.totalMemory();
long used = total - free;
log.info("Total memory: {}; Used memory: {}; Free memory: {}; Max memory: {}; No. of threads: {}",
return String.format("Total memory: %s; Used memory: %s; Free memory: %s; Max memory: %s; No. of threads: %s",
Utilities.readableFileSize(total),
Utilities.readableFileSize(used),
Utilities.readableFileSize(free),