0

Is it somehow possible, to figure out client PC CPU capabilities? I want my app to load only 25% of CPU or even 10% of CPU, but how much operations i should set, to avoid overloading it's CPU?

Have anyone tried to implement something like that?

For example 10 seconds Benchmark, how much operations fail etc.

Thanks :)

2 Answers 2

2

Make the code throttle itself dynamically. Run a bit of work and check how long time it took, then do a timeout based on that time.

Something like:

function work() { var t0 = new Date().getTime(); // do some part of the work var ms = new Date().getTime() - t0; window.setTimeout(work, ms * 10); } 

You can also use the time to decide how much work to do in the next iteration.

Sign up to request clarification or add additional context in comments.

Comments

0

You can't access the CPU via JavaScript.
JavaScript is running in your browser, and no browser delivers functionality for manipulating the CPU or any task control. This is some javascript benchmark thing, but not that what you really want I think.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.