Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance] on calcPmt() #221

Open
yellowbean opened this issue Oct 8, 2024 · 0 comments
Open

[Performance] on calcPmt() #221

yellowbean opened this issue Oct 8, 2024 · 0 comments

Comments

@yellowbean
Copy link
Owner

yellowbean commented Oct 8, 2024

Profile

stack exec --profile -- Hastructure-exe +RTS -p
~/.cabal/bin/profiteur Hastructure-exe.prof

Hastructure-exe.prof.html.zip

Stack Frame

Screenshot 2024-10-09 at 02 26 58

Result

The function "calcPmt" takes 95% of time in a pool run ( 300 mortgages), roughly 20 seconds in LOCAL

Screenshot 2024-10-09 at 02 29 43

Problem

How to optimize the function at

calcPmt bal 0.0 periods = divideBI bal periods
?

the logic seems simple and little room to improve ,is it the scenario that user shall replace this function with C DLL to boost performance ?( if it will boost )

The code pilot suggest, but it yields nothing, probably GHC has already optimized.

calcPmt bal periodRate periods =
    let
      periodRate1 = toRational periodRate
      r1 = (1 + periodRate1) ^ periods
      pmtFactor = periodRate1 * r1 / (r1 - 1)
    in
      mulBR bal pmtFactor
@yellowbean yellowbean linked a pull request Oct 8, 2024 that will close this issue
@yellowbean yellowbean removed a link to a pull request Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant