https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112009-06-19T03:06:30ZRuby Issue Tracking SystemRuby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=43272009-06-19T03:06:30Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul></ul><p>=begin<br>
Adding Time#to_int allows Range#include? to use its fast path, but I don't know if it is appropriate. There's a Process::Status#to_int so I suppose it would be valid for Time too.<br>
=end</p> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=43422009-06-20T02:16:59Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="/issues/1650">[ruby-core:23908]</a> [Bug <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: Time range === is slow (Rejected)" href="https://bugs.ruby-lang.org/issues/1650">#1650</a>] Time range === is slow"<br>
on Thu, 18 Jun 2009 09:48:30 +0900, Dmitry Bilunov <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> writes:</p>
<p>|The following program runs N times slower in ruby19 compared to ruby18.<br>
|N depends on the input range size.</p>
<p>1.9 Range#=== now checks according to enumeration (unless both ends<br>
are integers). It might be improved in the future, but until then, I<br>
recommend you to use t3.between?(t1, t2) instead of (t1 .. t2)===t3.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=46062009-07-13T21:44:15Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=149462010-12-29T05:45:59Zcdunn2001 (Christopher Dunn)cdunn2001@gmail.com
<ul></ul><p>=begin<br>
That's not what the docs say. They are ambiguous. <a href="http://ruby-doc.org/ruby-1.9/classes/Range.html" class="external">http://ruby-doc.org/ruby-1.9/classes/Range.html</a>:</p>
<ul>
<li>
<p>rng.cover?(val) => true or false<br>
Returns true if obj is between beg and end, i.e beg <= obj <= end (or end exclusive when exclude_end? is true).</p>
</li>
<li>
<p>rng.include?(val) => true or false<br>
Returns true if obj is an element of rng, false otherwise. If beg and end are numeric, comparison is done according magnitude of values.</p>
</li>
<li>
<p>rng === obj => true or false<br>
Returns true if obj is an element of rng, false otherwise. Conveniently, === is the comparison operator used by case statements.</p>
</li>
</ul>
<p>If Range#=== works exactly the same as Range#include?, the docs should say that. If they differ when beg/end are numeric, the docs should say that. I really do not know precisely how Range#=== works from the docs, the web, or this discussion. I have to test it myself. The distinction is critical because it may dramatically impact performance of 'case' statements in the move from 1.8 to 1.9.</p>
<p>Please update the docs with clarification.<br>
=end</p> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=149482010-12-29T06:42:51Zmarcandre (Marc-Andre Lafortune)marcandre-ruby-core@marc-andre.ca
<ul><li><strong>Category</strong> changed from <i>lib</i> to <i>doc</i></li><li><strong>Status</strong> changed from <i>Rejected</i> to <i>Open</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=182622011-06-26T13:57:00Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>akr (Akira Tanaka)</i></li></ul> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=183632011-06-26T16:43:06Znahi (Hiroshi Nakamura)nakahiro@gmail.com
<ul><li><strong>Target version</strong> set to <i>1.9.3</i></li></ul> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=185322011-06-27T01:59:06Zneleai (Ondrej Bilka)neleai@seznam.cz
<ul></ul><p>Ah bug I pointed out in ruby-core:8609<br>
currently there is following error.<br>
-:1:in <code>each': can't iterate from Time (TypeError) from -:1:in </code>include?'<br>
from -:1:in <code>include?' from -:1:in </code>==='<br>
from -:1:in `'</p>
<p>Anyway what is worse (Time.now - 1000000 .. Time.now) === (Time.now - 3)<br>
returns false as it enumerates Times and third time is usualy few<br>
microseconds off.</p>
<p>To me === expected behaviour is that (a..b)===c should call c.between?(a,b).</p>
<p>Problem at this time was that matz wanted in 1.9 ("a1".."a11") === "a9"<br>
return true (which in 1.8 returns false.<br>
This also could be slow for example for ("a1".."a1000000000") === "ab"</p>
<p>My proposal was call between and redefine String#between to do desired<br>
comparison as in patch attached at ruby-core:8609<br>
BTW patch is more general than one-char comparsion as is in<br>
range_include</p>
<p>On Sun, Jun 26, 2011 at 04:43:06PM +0900, Hiroshi NAKAMURA wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: Time range === is slow (Rejected)" href="https://bugs.ruby-lang.org/issues/1650">#1650</a> has been updated by Hiroshi NAKAMURA.</p>
<p>Target version set to 1.9.3</p>
<hr>
<p>Bug <a class="issue tracker-1 status-6 priority-4 priority-default closed" title="Bug: Time range === is slow (Rejected)" href="https://bugs.ruby-lang.org/issues/1650">#1650</a>: Time range === is slow<br>
<a href="http://redmine.ruby-lang.org/issues/1650" class="external">http://redmine.ruby-lang.org/issues/1650</a></p>
<p>Author: Dmitry Bilunov<br>
Status: Assigned<br>
Priority: Normal<br>
Assignee: Akira Tanaka<br>
Category: DOC<br>
Target version: 1.9.3<br>
ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [x86_64-linux]</p>
<p>=begin<br>
The following program runs N times slower in ruby19 compared to ruby18.<br>
N depends on the input range size.</p>
<p>dev@rails ~ $ time ruby19 -rtime -e '(Time.now - 1000000 .. Time.now) === (Time.now - 3)'</p>
<p>real 0m0.723s<br>
user 0m0.709s<br>
sys 0m0.013s<br>
dev@rails ~ $ time ruby18 -rtime -e '(Time.now - 1000000 .. Time.now) === (Time.now - 3)'</p>
<p>real 0m0.043s<br>
user 0m0.039s<br>
sys 0m0.005s<br>
=end</p>
<p>--<br>
<a href="http://redmine.ruby-lang.org" class="external">http://redmine.ruby-lang.org</a></p>
</blockquote>
<p>--</p>
<p>Network failure - call NBC</p> Ruby master - Bug #1650: Time range === is slowhttps://bugs.ruby-lang.org/issues/1650?journal_id=191092011-07-12T20:33:06Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Rejected</i></li></ul><p>Hello,</p>
<blockquote>
<p>If Range#=== works exactly the same as Range#include?, the docs should say that. If they differ when beg/end are numeric, the docs should say that.</p>
</blockquote>
<p>That is an implementation detail, I think. Not a bug. So I'm closing<br>
the ticket.<br>
If you want to clarify it as a spec, please register another ticket<br>
into feature tracker.</p>
<p>Thank you,</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>