我需要获取有关CPU / GPU /内存的任何信息。内核数量,内存值,内存和CPU使用情况...... 我为IE找到了一种方法:How to Use JavaScript to Find Hardware Information
其他浏览器的解决方案我不知道。知道怎么做吗? 也许webgl可以访问有关您的计算机的信息? 还是闪光? 或任何其他技术?
非常感谢
答案 0 :(得分:20)
此代码将打印GPU信息,将列出您可以使用此浏览器的性能对象获得的所有信息(BOM没有标准,因此每个浏览器都会更改)。
<html>
<body>
<canvas id="glcanvas" width="0" height="0"></canvas>
<script>
var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
document.write("<br>");
for (var value in performance) {
document.write(value + "<br>");
}
document.write("<br><br><br>");
var canvas;
canvas = document.getElementById("glcanvas");
var gl = canvas.getContext("experimental-webgl");
document.write(gl.getParameter(gl.RENDERER) + "<br>");
document.write(gl.getParameter(gl.VENDOR) + "<br>");
document.write(getUnmaskedInfo(gl).vendor + "<br>");
document.write(getUnmaskedInfo(gl).renderer + "<br>");
function getUnmaskedInfo(gl) {
var unMaskedInfo = {
renderer: '',
vendor: ''
};
var dbgRenderInfo = gl.getExtension("WEBGL_debug_renderer_info");
if (dbgRenderInfo != null) {
unMaskedInfo.renderer = gl.getParameter(dbgRenderInfo.UNMASKED_RENDERER_WEBGL);
unMaskedInfo.vendor = gl.getParameter(dbgRenderInfo.UNMASKED_VENDOR_WEBGL);
}
return unMaskedInfo;
}
</script>
</body>
&#13;
Chrome中的输出:
onresourcetimingbufferfull
onwebkitresourcetimingbufferfull
timing
navigation
memory
now
getEntries
getEntriesByType
getEntriesByName
clearResourceTimings
setResourceTimingBufferSize
webkitClearResourceTimings
webkitSetResourceTimingBufferSize
mark
clearMarks
measure
clearMeasures
addEventListener
removeEventListener
dispatchEvent
WebKit WebGL
WebKit
NVIDIA Corporation
NVIDIA GeForce GTX 775M OpenGL Engine
Firfox的输出:
now
getEntries
getEntriesByType
getEntriesByName
clearResourceTimings
setResourceTimingBufferSize
mark
clearMarks
measure
clearMeasures
toJSON
timing
navigation
onresourcetimingbufferfull
Mozilla
Mozilla
Safari中的输出:
navigation
timing
now
WebKit WebGL
WebKit
NVIDIA Corporation
NVIDIA GeForce GTX 775M OpenGL Engine
答案 1 :(得分:11)
答案 2 :(得分:7)
我写了这个快速脚本来获得cpu速度:
var _speedconstant = 8.9997e-9; //if speed=(c*a)/t, then constant=(s*t)/a and time=(a*c)/s
var d = new Date();
var amount = 150000000;
var estprocessor = 1.7; //average processor speed, in GHZ
console.log("JSBenchmark by Aaron Becker, running loop "+amount+" times. Estimated time (for "+estprocessor+"ghz processor) is "+(Math.round(((_speedconstant*amount)/estprocessor)*100)/100)+"s");
for (var i = amount; i>0; i--) {}
var newd = new Date();
var accnewd = Number(String(newd.getSeconds())+"."+String(newd.getMilliseconds()));
var accd = Number(String(d.getSeconds())+"."+String(d.getMilliseconds()));
var di = accnewd-accd;
//console.log(accnewd,accd,di);
if (d.getMinutes() != newd.getMinutes()) {
di = (60*(newd.getMinutes()-d.getMinutes()))+di}
spd = ((_speedconstant*amount)/di);
console.log("Time: "+Math.round(di*1000)/1000+"s, estimated speed: "+Math.round(spd*1000)/1000+"GHZ");
请注意,这取决于浏览器选项卡,内存使用情况等,但如果您只运行一次,例如在加载页面时,我发现它非常准确。
对于桌面设备,尤其是PC,这可能不准确,但我只在其他解决方案(例如第一个解决方案失败)时才在我的网站中使用它,以便仅使用移动设备的平均速度(允许我估算使用的核心)客户端JS。它可能不是最好的,但它确实很好。
如果您希望更改_speed常量以更改速度,只需使用公式(knowncpuspeed * knowntimetocomplete)/ knowncycles计算它。希望你觉得这很有用!
更新10/19/17:为新的Chrome V8 JS引擎更改了_speedconstant,并添加了关于我使用它的部分。