Using PromiseWorker was an excellent choice. My script is approximately 20 times faster while running in a separate thread… In the main thread, my script needs ~250 s to perform all the tests. In a separate thread, it takes 12-13 s.
That’s a huge difference. I can’t stop wondering why it’s so slow in the main thread.
Very cool. Probably because there’s nothing else that thread. So it’s not waiting on other operations to finish before getting to your operations.
Speed isn’t the main reason for the thread. It’s mostly for keeping the main thread running smooth. As main thread is GUI. So in case you get slower speeds don’t worry and revert back to main thread. There is still a usability gain.
I didn’t use a PromiseWorker with the expectation it might go faster. The documentation says nothing about that. I wanted to prevent Firefox from freezing.
Yes. That’s what we can guess…
But…
These tests just perform data analysis. I can launch them when there is no interaction with the UI, no web page loaded, when Firefox is just empty and does nothing else… and it’s still 20 times slower than with a separate thread. That’s why it’s so surprising.