当前位置:网站首页>OperatingSystemMXBean to get system performance metrics
OperatingSystemMXBean to get system performance metrics
2022-08-02 02:46:00 【LG_985938339】
OperatingSystemMXBeanGet system performance metrics
| 方法名称 | 含义 | 单位 |
|---|---|---|
| getFreePhysicalMemorySize | 可用物理内存 | 字节 |
| getTotalPhysicalMemorySize | 总物理内存 | 字节 |
| getFreeSwapSpaceSize | 可用交换空间 | 字节 |
| getTotalSwapSpaceSize | 交换空间总量 | 字节 |
| getCommittedVirtualMemorySize | Committed virtual memory size | 字节 |
| getProcessCpuLoad | 进程CPU使用率(0~1之间) | |
| getSystemCpuLoad | 系统CPU使用率(0~1之间) | |
| getAvailableProcessors | 可用CPU核数 | 个 |
| getProcessCpuTime | 进程使用的 CPU 时间 | 纳秒 |
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;
public class Test {
public static void main(String[] args) throws InterruptedException {
final long GB = 1024 * 1024 * 1024;
OperatingSystemMXBean operatingSystemMXBean = (OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
System.out.println("进程CPU使用率: "+operatingSystemMXBean.getProcessCpuLoad()* 100+"%");
System.out.println("系统CPU使用率: "+operatingSystemMXBean.getSystemCpuLoad()* 100+"%");
System.out.println("物理内存总量: "+operatingSystemMXBean.getTotalPhysicalMemorySize()/GB+"GB");
System.out.println("The remaining available amount of physical memory: "+operatingSystemMXBean.getFreePhysicalMemorySize()/GB+"GB");
System.out.println("内存使用率: "+(double)100*operatingSystemMXBean.getFreePhysicalMemorySize()/operatingSystemMXBean.getTotalPhysicalMemorySize()+"%");
System.out.println("交换空间总量: "+operatingSystemMXBean.getTotalSwapSpaceSize()/GB+"GB");
System.out.println("The amount of swap space remaining available: "+operatingSystemMXBean.getFreeSwapSpaceSize()/GB+"GB");
System.out.println("CPU核心数: "+operatingSystemMXBean.getAvailableProcessors()+"个");
System.out.println("Amount of virtual memory committed: "+operatingSystemMXBean.getCommittedVirtualMemorySize());
System.out.println("process usedCPU时间: "+operatingSystemMXBean.getProcessCpuTime()/1000000000.0+"秒");
}
}
边栏推荐
猜你喜欢

面对职场“毕业”,PM&PMO应该如何从容的应对?如何跳槽能够大幅度升职加薪?

qt点云配准软件

Flask 报错:WARNING This is a development server. Do not use it in a production deployment

BioVendor Human Club Cellular Protein (CC16) Elisa Kit Research Fields

ReentrantLock工作原理

Chopper webshell feature analysis

最大层内元素和

Lombok

Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!

ApiFox 基本使用教程(浅尝辄止,非广)
随机推荐
局部敏感哈希:如何在常数时间内搜索Embedding最近邻
ApiFox 基本使用教程(浅尝辄止,非广)
240...循迹
微信小程序异步回调函数恶梦和解决办法
51. 数字排列
Talking about the "horizontal, vertical and vertical" development trend of domestic ERP
(1) Redis: Key-Value based storage system
【LeetCode】145.二叉树的后序遍历
Remember a gorm transaction and debug to solve mysql deadlock
ros多客户端请求服务
AI target segmentation capability for fast video cutout without green screen
字符串常用方法
NIO's Sword
淘宝详情.
欧拉公式的证明
Outsourcing worked for three years, it was abolished...
Remember a pit for gorm initialization
isa指针使用详情
很有意思的经历,很有意思的项目--文件夹对比工具
BioVendor人俱乐部细胞蛋白(CC16)Elisa试剂盒研究领域