当前位置:网站首页>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+"秒");
}
}
边栏推荐
- JS中获取对象数据类型的键值对的键与值
- IPFS部署及文件上传(golang)
- NIO‘s Sword(牛客多校赛)
- OC中成员变量,实例变量和属性之间的区别和联系
- 【LeetCode】145.二叉树的后序遍历
- MySQL索引优化实战
- yaml
- Remember a pit for gorm initialization
- Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!
- The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
猜你喜欢
国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现
FOFAHUB usage test
Nacos源码分析专题(一)-环境准备
Lombok
网络层解析——IP协议、地址管理、路由选择
esp32经典蓝牙和单片机连接,,,手机蓝牙作为主机
Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
ros多客户端请求服务
BioVendor Human Club Cellular Protein (CC16) Elisa Kit Research Fields
Flask入门学习教程
随机推荐
灰度传感器、、、diy原理。。图
淘宝详情.
esp32经典蓝牙和单片机连接,,,手机蓝牙作为主机
ApiFox 基本使用教程(浅尝辄止,非广)
Unable to log in to the Westward Journey
微服务:微智能在软件系统的简述
欧拉公式的证明
Use DBeaver for mysql data backup and recovery
Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
The failure to create a role in Dahua Westward Journey has been solved
2022牛客多校四_G M
亲身经历过的面试题
使用docker安装mysql
使用self和_(下划线)的区别
cocos中使用async await异步加载资源
The state status is displayed incorrectly after the openGauss switch
OC中new和init的区别
analog IC layout
mockjs生成假数据的基本使用
2022 NPDP take an examination of how the results?How to query?