niklas-heer / speed-comparison

A repo which compares the speed of different programming languages.
https://niklas-heer.github.io/speed-comparison
MIT License
508 stars 79 forks source link

Faster R startup #51

Closed jonocarroll closed 2 years ago

jonocarroll commented 2 years ago

Again credit to @HenrikBengtsson

niklas-heer commented 2 years ago

@jonocarroll thanks again for your contribution! :)

HenrikBengtsson commented 2 years ago

For me, it still looks like only the standard library is used. Is that correct?

Correct. R loads several built-in packages by default for convenience to the user. This patch tells R to only load the 'base' package, which is the core package that contains the bare minimum in R and that always must be loaded.

So, this tweak minimizes the R startup time. I'd imagine some of the other language engines can be tweaked this way too.

For you overall goal, to benchmark the calculation of pi, I think it would be better if you could find a way to not include the startup times, and the parsing of 'rounds.txt' in the results. A poor man's solution would be to benchmark each language with and without the part that calculates pi and the subtract to get the timings of interest.

niklas-heer commented 2 years ago

@HenrikBengtsson thank you very much for the explanation, that makes sense. 👍

For you overall goal, to benchmark the calculation of pi, I think it would be better if you could find a way to not include the startup times, and the parsing of 'rounds.txt' in the results. A poor man's solution would be to benchmark each language with and without the part that calculates pi and the subtract to get the timings of interest.

First things first: Thank you for the poor man's solution suggestion that is simple, but brilliant. Something which wouldn't require too much rewriting.

Side story: I think I don't really know what my goal is with this repo. To be honest, when I started it was for me more about learning how to do something like this rather than answering the specific question on how good languages are at computing pi through the Leibniz formula. I'm surprised and delighted that it picked up quite a bit of popularity all of a sudden after 5 years. 😅

Regarding the goal moving forward: I always liked that it tested more of a "real-world scenario" including reading a file and starting up the language (if that is how the language is implemented). But maybe I can do both. Provide "clean" results and more "real world" results. 🤔