webworkerUtil2

After some test

I took a simple algorithm randomly on the web, I wanted tested fastly….

You can see the result (yeah,I know, messy, and comment in french !) :
my test

The result is interesting !
First the number of thread allow by Chrome is very few: 4 only.
Same for firefox… Compare to the true number in actual CPU, it is very few !

The algorithm I took is little special: compute between 0..10000 is lot more fast than 100000..110000.

So as a result :
At begin I forgot one thread do only one computation !
So I have in this case to do an array of worker…Perhaps more smart to expose something like “clone()”…
Or to do it without ask the programmer ?

So my first test was not so good but, If I go in big number: Chrome die in normal way, not on worker.

we go from 3.2 s to less than 2s…but this algorithm is really a special case.

My second test was more “smart”: I don’t send my 4 thread on 1/4 of data, but i send 4 thread on small parts,
And I reutilise them when they did the work.

Even my source are messy, it is not so complicate to understand I think.
so from the classical algorithm,we go from 3.2s to 0.45s.

The step of data I give look important, I tried many value.
too small was bad as 1.4s, to the best who was 0.45s.

Not so bad for so few work !

(and It was fun ! )