string/concatenation.rb tests are misleading
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 45/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- ruby
- 領域
- performance, testing
調査の方向性
string/concatenation.rb から始めて、現在のベンチマークが高速なメソッドをどのように定義し、連結方法を比較しているかを調べます。比較には実行時変数を使い、issue の benchmark-ips の例を基準にします。ベンチマークがパーサー時の連結を実行時の操作として扱わず、示されている代替手段を公平に比較するようになれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi, the tests in string/concatenation.rb are quite misleading.
The fast method consists of this
def fast
'foo' 'bar'
end
That's not concatenating during calling of fast but on parsing the code. If you write another method just returning foobar, it is as fast as this method.
So I think this is not fair comparison and what you usually want is to concatenate two variables during runtime.
For this use case concat and << are calling the same code, so they have the same performance and both are fine if you want to change the string on the left and not just get two strings concatenated. If you want a new string you can use +.
Some better test could be to compare + and String interpolation
Benchmark.ips do |x|
foo = 'foo'
bar = 'bar'
x.report('String#+') do
foo + bar
end
x.report('String interpolation') do
"#{foo}#{bar}"
end
x.compare!
end
This still has the difference that interpolation can handle nil values, while + cannot.
- 主要言語
- Ruby
- スター
- 5.7k
- フォーク
- 370
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fastruby/fast-ruby のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
fastruby/fast-ruby の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
riscv/riscv-unified-db#2624 · リアクション 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100