fastruby / fast-ruby

:dash: Writing Fast Ruby :heart_eyes: -- Collect Common Ruby idioms.
https://github.com/fastruby/fast-ruby
5.67k stars 376 forks source link

Randomized string concat #216

Closed alekseyl closed 1 year ago

alekseyl commented 1 year ago

proposition for https://github.com/fastruby/fast-ruby/issues/158 fix.

alekseyl commented 1 year ago

Thnx @JuanVqz, no worries for the delay :). I've commited suggested!

JuanVqz commented 1 year ago

@mateusdeap could you please have a look to merge it?

alekseyl commented 1 year ago

@alekseyl @JuanVqz I noticed that this PR uses bmbm and we want all benchmarks to use ips Could you please tweak this benchmark to use "benchmark/ips"? It shouldn't affect the results. Thanks!

@etagwerker Hi Ernesto!

Sorry for the delayed answer. The problem is it will not look as good as we migh expect, because of a randomization )). It will show a much bigger variance (20-30-40% I can't recall properly) over relatively "small" difference.

I might give it a try one more time, but can't promise that it will be soon enough :(. I need an inspiration to dive in to that river again ))).

ixti commented 1 year ago

Can we also add:

[foo, bar].join

It would also make sense to check if there will be different results with more than 2 strings to concatenate. Also, would be nice to see performance comparison of cases like:

"#{foo}-#{bar}"