niklas-heer / speed-comparison

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

vectorized R #45

Closed jonocarroll closed 1 year ago

jonocarroll commented 1 year ago

(simple PR via the web interface). I haven't run the comparison myself, but if that's possible via CI prior to merge it would be useful to review.

jonocarroll commented 1 year ago

The speedup is about what I predicted, though I suppose my M1 mac runs a bit quicker than the CI.

combined_results

niklas-heer commented 1 year ago

That is true, it's a 2-core Ubuntu machine AFAIK. Thank you for your contribution @jonocarroll :+1:

Moelf commented 1 year ago

isn't vectorized R calling the underlying library? this shouldn't be allowed because then Python should be allowed to use Numpy?

niklas-heer commented 1 year ago

As far as I understand it, it is part of the standard library of R which would be the deciding factor for me. Whereas NumPy is an additional package which would need to be installed. Correct me if I'm wrong.

jonocarroll commented 1 year ago

R is vectorised by design in the sense that operations like a + b (in this case, the division and sum()) can take vectors without users needing to write a loop. There is of course a loop, but it happens in the internals. I actually have a post on this: https://jcarroll.com.au/2022/04/22/where-for-loop-art-thou/