T
T
Tomato Potato2019-10-08 17:51:07
JavaScript
Tomato Potato, 2019-10-08 17:51:07

How to limit CPU power consumption for executing JS code in Chrome?

Hello.
I study array sorting algorithms, write JS code, run it in Chrome under Win 10. There are no problems with small arrays, but as soon as I try to sort large ones, problems begin. Chrome takes everything from life and clogs the processor at 100%, but I would like to perform some more tasks in parallel, it is relatively comfortable while the array is being sorted. Actually, the question is how not to let the executing JS code (in my case, sorting the array) consume 100% of the processor, but to specify that it uses, say, 50%? Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Stolyarov, 2019-10-08
@Ni55aN

The question is not in eating the CPU (it cannot be limited in any way in the browser, you can only reduce the number of operations per unit of time), but in blocking the main thread. Solution - Web Workers

G
grinat, 2019-10-08
@grinat

Do it in a node, a node in a virtual machine, you can set as much as you need there.

A
ApeCoder, 2019-10-08
@ApeCoder

Run chrome at a lower priority (start /low in cmd) or lower its priority in the task manager

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question