How can I check the computing power of a user's computer using Javascript?

I made a pretty intense webpage with lots of CSS3 and Javascript. I want to use Javascript to check if a user computer can process scripts. I think a possible method is to run scripts with heavy CPU usage and see how much time has passed. However, I do not know how to implement this.

Here's the web page: http://leojiang.me/ (the 3D cube is only viewable in webkit browsers).

+4
javascript cpu css3
source share
3 answers

You can specify how long it takes to render a frame or several frames, which should give you an idea of ​​what fps will be on the client.

var StartTime = new Date().getTime(); BenchMarkTestFunction(); // render frame for example var EndTime = new Date().getTime(); var ElapsedMilliseconds = EndTime - StartTime; var AcceptableTime = 1000; // one second var IsGoodPerformance = ElapsedMilliseconds < AcceptableTime; // some number being acceptable performace if(!IsGoodPerformance) { alert("Sorry your browser is not good enough to run this site - go somewhere else"); } 

You can determine what AcceptableTime should be by checking your site on different browsers / devices and seeing how it works and what is the meaning of ElapsedMilliseconds.

+7
source share

Preventing the installation of localstorage to run the script (in fact, hacking the user machine - do not do this), I do not think that you can do anything but find the OS and architecture. It seems to me that I saw this in a flash, but strictly js will not find the speed. I agree with Scott. If your potential users may have problems, reverse engineer them. Otherwise, my i5 was completely satisfied with the site. Good luck

0
source share

There are ways to evaluate the processor or graphics capabilities of the host using javascript. For example, you can start a set of iterations using these operations and measure the time from start to finish.

In general, it’s not so useful to just try to measure one CPU performance number, since it is much more important to determine exactly what your critical operations are.

For example, if you are interested in a certain type of graphics rendering, you can make a sample animation and see how many frames can be displayed at a certain time.

0
source share

All Articles