https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112020-08-20T14:06:52ZRuby Issue Tracking SystemRuby master - Feature #17127: Some TrueClass methods are faster if implemented in Rubyhttps://bugs.ruby-lang.org/issues/17127?journal_id=871432020-08-20T14:06:52ZS_H_ (Shun Hiraoka)gamelinks007@gmail.com
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87143/diff?detail_id=57768">diff</a>)</li></ul> Ruby master - Feature #17127: Some TrueClass methods are faster if implemented in Rubyhttps://bugs.ruby-lang.org/issues/17127?journal_id=871452020-08-20T15:58:37Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Subject</strong> changed from <i>Some TrueClass methods is faster if implemented in Ruby</i> to <i>Some TrueClass methods are faster if implemented in Ruby</i></li><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87145/diff?detail_id=57770">diff</a>)</li></ul> Ruby master - Feature #17127: Some TrueClass methods are faster if implemented in Rubyhttps://bugs.ruby-lang.org/issues/17127?journal_id=871532020-08-21T18:37:25Zk0kubun (Takashi Kokubun)takashikkbn@gmail.com
<ul></ul><p>off topic: If you write an entire ticket in English, I think you should post your ticket to ruby-core to attract more audiences instead of ruby-dev, which has been for tickets written in Japanese.</p> Ruby master - Feature #17127: Some TrueClass methods are faster if implemented in Rubyhttps://bugs.ruby-lang.org/issues/17127?journal_id=871702020-08-24T14:34:40ZS_H_ (Shun Hiraoka)gamelinks007@gmail.com
<ul></ul><p>k0kubun (Takashi Kokubun) wrote in <a href="#note-3">#note-3</a>:</p>
<blockquote>
<p>off topic: If you write an entire ticket in English, I think you should post your ticket to ruby-core to attract more audiences instead of ruby-dev, which has been for tickets written in Japanese.</p>
</blockquote>
<p>Thanks!</p> Ruby master - Feature #17127: Some TrueClass methods are faster if implemented in Rubyhttps://bugs.ruby-lang.org/issues/17127?journal_id=871952020-08-26T09:05:28ZS_H_ (Shun Hiraoka)gamelinks007@gmail.com
<ul></ul><p>these method able to speeding up implemented by Ruby code.</p>
<ul>
<li><code>TrueClass#^</code></li>
<li><code>TrueClass#&</code></li>
</ul>
<p>benchmark:</p>
<pre><code class="yaml syntaxhl" data-language="yaml"><span class="na">benchmark</span><span class="pi">:</span>
<span class="na">to_s</span><span class="pi">:</span> <span class="pi">|</span>
<span class="s">true.to_s</span>
<span class="na">inspect</span><span class="pi">:</span> <span class="pi">|</span>
<span class="s">true.inspect</span>
<span class="na">or</span><span class="pi">:</span> <span class="pi">|</span>
<span class="s">true | false</span>
<span class="na">xor</span><span class="pi">:</span> <span class="pi">|</span>
<span class="s">true ^ false</span>
<span class="na">and</span><span class="pi">:</span> <span class="pi">|</span>
<span class="s">true & false</span>
<span class="na">loop_count</span><span class="pi">:</span> <span class="m">1000000</span>
</code></pre>
<p>result:</p>
<pre><code class="bash syntaxhl" data-language="bash">sh@MyComputer:~/rubydev/build<span class="nv">$ </span>make benchmark/trueclass.yml <span class="nt">-e</span> <span class="nv">COMPARE_RUBY</span><span class="o">=</span>~/.rbenv/shims/ruby <span class="nt">-e</span> <span class="nv">BENCH_RUBY</span><span class="o">=</span>../install/bin/ruby
<span class="c"># Iteration per second (i/s)</span>
| |compare-ruby|built-ruby|
|:--------|-----------:|---------:|
|to_s | 63.991M| 93.655M|
| | -| 1.46x|
|inspect | 83.655M| 96.044M|
| | -| 1.15x|
|or | 38.138M| 77.149M|
| | -| 2.02x|
|xor | 61.388M| 76.603M|
| | -| 1.25x|
|and | 59.928M| 71.783M|
| | -| 1.20x|
</code></pre>
<p><code>COMPARE_RUBY</code> is <code>ruby 2.8.0dev (2020-08-26T05:28:05Z master 72cb9bc55f) [x86_64-linux]</code>. <code>BENCH_RUBY</code> is patched ruby.</p> Ruby master - Feature #17127: Some TrueClass methods are faster if implemented in Rubyhttps://bugs.ruby-lang.org/issues/17127?journal_id=883582020-11-05T07:11:51ZS_H_ (Shun Hiraoka)gamelinks007@gmail.com
<ul></ul><p>recreate PR for merge <code>.rb</code> files</p>
<p><a href="https://github.com/ruby/ruby/pull/3737" class="external">https://github.com/ruby/ruby/pull/3737</a></p>