Continuing the discussion from A short history of ReScript (BuckleScript): thought I’d start a new thread instead of continuing there since it was getting fairly OT.
You have a nice fast machine. By way of comparison, how long does the native ocamlopt code take to solve the prime?
Thanks It’s a little indulgence for trying out different tech stacks. The native and bytecode benchmarks:
$ ./primes.opt
Elapsed time: 0.142687
1299709
$ ./primes.byte
Elapsed time: 0.475783
1299709
Loading it in the head seems to improve the chance of the JITer getting on the fast path, particularly if reloading the page.
Interesting. I made the change and get the following:
- Firefox: 0.105s (before: 0.117s, seems like a speedup)
- Chromium: 0.095s (before: 0.094s, doesn’t seem like a significant difference)
if I tweak your rescript-generated primes.js file by omitting the imports of curry.js and caml_int32.js and substituting standard javascript, the rescript version runs slightly faster than the JSOO version in chrome and slightly slower in firefox.
Yeah, the ‘curry’ stuff is because the compiler has to check whether the return value is a curried function or if it’s fully applied. There’s actually support for totally uncurried functions, with [@bs]
annotation in OCaml syntax and dedicated ergonomic syntax in ReScript. I purposely didn’t use that though because I typically wouldn’t use it unless performance was actually a concern.