Thread overview | |||||
---|---|---|---|---|---|
|
August 24, 2018 Parallelizing factorial computation | ||||
---|---|---|---|---|
| ||||
I was messing and tried comparing the performance of different ways to compute the factorial of a number. Here's the benchmark results: recursive: 244 ms, 283 μs, and 2 hnsecs loop: 241 ms, 412 μs, and 3 hnsecs parallel: 1 sec, 784 ms, 829 μs, and 5 hnsecs https://run.dlang.io/is/uyVlqu I was quite surprised by the fact that parallel ran so much slower than recursive and loop implementations. Does anyone know why? |
August 24, 2018 Re: Parallelizing factorial computation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Uknown | On Friday, 24 August 2018 at 13:04:47 UTC, Uknown wrote: > I was quite surprised by the fact that parallel ran so much slower than recursive and loop implementations. Does anyone know why? n = 100 is too small to see parallelism gains. Try n = 10000 https://run.dlang.io/is/XDZTSd |
August 25, 2018 Re: Parallelizing factorial computation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | On Friday, 24 August 2018 at 20:43:46 UTC, Peter Alexander wrote:
> On Friday, 24 August 2018 at 13:04:47 UTC, Uknown wrote:
>> I was quite surprised by the fact that parallel ran so much slower than recursive and loop implementations. Does anyone know why?
>
> n = 100 is too small to see parallelism gains.
>
> Try n = 10000
>
> https://run.dlang.io/is/XDZTSd
I was using n = 10000 originally, I reduced it because that wasn't running on run.dlang. Tried this again on my machine and you were right.
|
Copyright © 1999-2021 by the D Language Foundation