如何在JavaScript中获得CPU使用率? [英] How to get CPU usage in JavaScript?

查看:676
本文介绍了如何在JavaScript中获得CPU使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在浏览器中的JavaScript中获得CPU使用率?

Is there a way to get the CPU(s) usage in JavaScript on the browser?

推荐答案

收集到的信息,您可以在浏览器中从本机中找到的有关JS CPU统计信息的最多信息是客户端使用的 CPU内核数量。将此插入到您的JS文件中:

From what I have gathered, the most you can find out natively in the browser about JS CPU stats, is the amount of CPU cores the client is using. Insert this in your JS file:

console.log(navigator.hardwareConcurrency)

然后您可以在Chrome开发工具控制台中进行检查。

You can then check that in the Chrome Dev Tools console.

但是,您可以使用Node.js 计算CPU负载。 这是逐步的。

However, you can calculate the CPU load using Node.js. Here is a step-by-step on that.

此页面上的答案也可能在您遇到两难时有所帮助: Javascript-动态监视CPU /内存使用情况

The answer on this page may also be of help in your dilemma: Javascript- Dynamically monitor CPU/memory usage

这篇关于如何在JavaScript中获得CPU使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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