Why is this code slow?
matheus
matheus at gmail.com
Sun Mar 24 20:34:19 UTC 2024
On Sunday, 24 March 2024 at 19:31:19 UTC, Csaba wrote:
> ...
>
> Here are the results:
>
> C: 0.04s
> Python: 0.33s
> D: 0.73s
>
> ...
I think a few things can be going on, but one way to go is trying
using optimization flags like "-O2", and run again.
But anyway, looking through Assembly generated:
C: https://godbolt.org/z/45Kn1W93b
D: https://godbolt.org/z/Ghr3fqaTW
The Leibniz's function is very close each other, except for one
thing, the "pow" function on D side. It's a template, maybe you
should start from there, in fact I'd try the pow from C to see
what happens.
Matheus.
More information about the Digitalmars-d-learn
mailing list