使用 Java 检测 CPU 速度/内存/互联网速度? [英] Detect CPU Speed/Memory/Internet Speed using Java?

查看:43
本文介绍了使用 Java 检测 CPU 速度/内存/互联网速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Java 中识别可用的总 CPU 速度以及总系统内存?到网络的网络连接速度也很棒.

Is it possible within Java to identify the total CPU speed available as well as the total system memory? Network connection speed to the web would also be awesome.

推荐答案

这真的取决于你的操作系统,因为 Java 会告诉你关于底层机器的很少.不幸的是,您必须根据您的操作系统使用不同的方法.

This really depends on your OS, since Java will tell you little about the underlying machine. Unfortunately you have to use differing approaches depending on your OS.

如果您使用的是 Linux,请查看 /proc/cpuinfo 文件系统以获取 CPU 信息./proc 通常有丰富的信息.网络 (IO) 将通过命令 ifconfig 反映.

If you're on Linux, take a look at the /proc/cpuinfo filesystem for CPU info. /proc generally has a wealth of information. Network (IO) will be reflected via the command ifconfig.

如果您使用的是 Windows,一个有用的工具是 WMI,它提供对各种低级硬件统计信息的访问.您可以通过 CScript.这是 WMI 脚本示例的页面.

If you're on Windows, a useful tool is WMI, which provides access to all sorts of low-level hardware stats. You can run WMI scripts via CScript. Here's a page of examples of WMI scripts.

这篇关于使用 Java 检测 CPU 速度/内存/互联网速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆