Get CPU/GPU/memory information
This code will print GPU infos an will list all info you can have with the performance object of this browser (there is no standard for the BOM so it changes for each browser).
<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>
Output in Chrome :
onresourcetimingbufferfullonwebkitresourcetimingbufferfulltimingnavigationmemorynowgetEntriesgetEntriesByTypegetEntriesByNameclearResourceTimingssetResourceTimingBufferSizewebkitClearResourceTimingswebkitSetResourceTimingBufferSizemarkclearMarksmeasureclearMeasuresaddEventListenerremoveEventListenerdispatchEventWebKit WebGLWebKitNVIDIA CorporationNVIDIA GeForce GTX 775M OpenGL Engine
Output in Firfox :
nowgetEntriesgetEntriesByTypegetEntriesByNameclearResourceTimingssetResourceTimingBufferSizemarkclearMarksmeasureclearMeasurestoJSONtimingnavigationonresourcetimingbufferfullMozillaMozilla
Output in Safari :
navigationtimingnowWebKit WebGLWebKitNVIDIA CorporationNVIDIA GeForce GTX 775M OpenGL Engine
I wrote this quick script to get the cpu speed:
var _speedconstant = 8.9997e-9; //if speed=(c*a)/t, then constant=(s*t)/a and time=(a*c)/svar d = new Date();var amount = 150000000;var estprocessor = 1.7; //average processor speed, in GHZconsole.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");
Note that this depends on browser tabs, memory use, etc. but I found it pretty accurate if you only run it once, say at the loading of a page.
This may not be accurate for desktop devices, especially PCs, but I use it in my website only when other solutions like the first one fail, for getting the average speed of mobile devices (allows me to estimate cores used) using only client-side JS. It may not be the best, but it does pretty well.
If you would like you can change the _speedconstant to change the speed, just calculate it with the equation (knowncpuspeed*knowntimetocomplete)/knowncycles. Hope you find this useful!
UPDATE 10/19/17: Changed _speedconstant for the new chrome V8 JS engine and added section about what I use it for.