Vince
Vince

Reputation: 589

Web Workers performance expectations

I'm considering using Web Workers to for batch image processing and am wondering what to expect in terms of performance gains.

My current strategy is to process each image in sequence and only start a new process after the current process is over. If I have 10 images that take 10 seconds each to process, the batch will complete in ~100 seconds.

If I use 10 Web Workers at once, I doubt I will complete the entire job in 10 seconds. But will it be lower than 100 seconds? If not, is there an optimal size to a pool of concurrently running Web Workers?

Upvotes: 2

Views: 907

Answers (2)

knutole
knutole

Reputation: 1787

You can try to experiment with this example: Ray-tracing with Web Workers It certainly seems there is a huge performance gain in using 16 vs. 4 web workers here.

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180787

I would imagine that your performance gains will depend heavily on the number of cores you have in your computer. If I were to guess, I'd say a good sweet spot might be four web workers (corresponding to quad-core machines), but the only way to know for sure is to try it out.

Structure your code in such a way that you can simply change a constant to change the number of workers, and then set it to a value that seems to work optimally.

Upvotes: 1

Related Questions