|
|
|
|
|
by pmontra
1683 days ago
|
|
> Rewriting from Ruby to Go, some benchmarks for calculating long streaks showed going from ~5 sec to ~0.04 sec [2]. This is why sometimes it's worth looking for obscure methods in the core or standard library and use them instead of writing Ruby code, especially when iterating on Enumerables. Basically it's rewriting Ruby in C. Entry level example: minmax_by [1] which does the obvious thing but it's not obvious that every Ruby developer knows about it (disclaimer: I went to the docs and looked for something with a fun name.) [1] https://ruby-doc.org/core-3.0.1/Enumerable.html#method-i-min... |
|