I just need to check out the parallel collections a bit, and I used the following line of code (in REPL):
(1 to 100000).par.filter(BigInt(_).isProbablePrime(100))
against
(1 to 100000).filter(BigInt(_).isProbablePrime(100))
But the parallel version is not faster. In fact, it even feels a little slower (but I did not).
Is there any explanation for this?
Edit 1: Yes, I have a multi-core processor
Edit 2: Ok, I myself "solved" the problem. The implementation of isProbablePrime
seems to be a problem, not parallel collections. I replaced isProbablePrime
with another function to test for simplicity, and now I get the expected acceleration.
Plankalkül
source share