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 difference between v4.11 and v5.1+ ?? (on a tiny snippet of recursive OCaml code) #76

Open
Naereen opened this issue Sep 11, 2024 · 0 comments

Comments

@Naereen
Copy link
Contributor

Naereen commented Sep 11, 2024

Hi there,
I recently tested on your version the latest v5.1+ version, with the following piece of code:

let rec binom k n =
    if k < 0 || k > n then 0
    else if k = 0 || k = n then 1
    else binom k (n - 1) + binom (k - 1) (n - 1)
;;

let debut = Sys.time() in
let b_15_30 = binom 15 30 in
let fin = Sys.time() in
Printf.printf "binom 15 30 a pris %g secondes\n" (fin -. debut);
b_15_30;;

It gives about 3.5 seconds on http://ocaml.besson.link/, hosting the version 4.14.1 of BetterOCaml, and about 16.117 seconds on your most recent version on https://jbdoderlein.github.io/BetterOCaml/?version=5.1.1.

Is there any reason for such a large difference?
I don't have a v5+ OCaml toplevel installed locally and won't install it now, so I can't test offline, but the difference seems huge.

Thanks for the answer, if you have any idea why 😄 !

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