Ruby Issue Tracking System: Issueshttps://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112014-08-23T21:01:47ZRuby Issue Tracking System
Redmine Ruby master - Feature #10165 (Closed): Use Process.clock_gettime to speed up Benchmark.realtime.https://bugs.ruby-lang.org/issues/101652014-08-23T21:01:47Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>This patch changes the Benchmark.realtime method to use the Process.clock_gettime internally when generating the time elapsed. Calling Process.clock_gettime is faster than the current way of creating Time objects.</p>
<p>I wrote a benchmark script (also attached) to demonstrate the difference:</p>
<pre><code>require 'benchmark'
def old_benchmark
r0 = Time.now
yield
Time.now - r0
end
def new_benchmark
r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield
Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0
end
n = (ARGV.first || 1_000_000).to_i
puts "#{n} iterations."
Benchmark.bmbm do |b|
b.report("old") { n.times { old_benchmark { nil } } }
b.report("new") { n.times { new_benchmark { nil } } }
end
</code></pre>
<p>When I run this on my local machine I see this output:</p>
<pre><code>1000000 iterations.
Rehearsal ---------------------------------------
old 0.860000 0.000000 0.860000 ( 0.863118)
new 0.360000 0.000000 0.360000 ( 0.355242)
------------------------------ total: 1.220000sec
user system total real
old 0.870000 0.010000 0.880000 ( 0.866577)
new 0.330000 0.000000 0.330000 ( 0.328982)
</code></pre>
<p>I discussed this idea originally with Eric Hodel, but he has not reviewed this code.</p> Ruby master - Feature #8478 (Open): The hash returned by Enumerable#group_by should have an empty...https://bugs.ruby-lang.org/issues/84782013-06-03T04:37:46Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>Without this patch, nil checks might need to be done on the return value of Enumerable#group_by:</p>
<p>$ cat test_group_by.rb<br>
a = [1, 2, 3, "a", "b"]<br>
g = a.group_by {|o| o.class }</p>
<p>puts "Fixnums: #{g[Fixnum].size}"<br>
puts "Strings: #{g[String].size}"<br>
puts "Arrays: #{g[Array].size}"</p>
<p>$ ruby test_group_by.rb<br>
Fixnums: 3<br>
Strings: 2<br>
test_group_by.rb:6:in <code><main>': undefined method </code>size' for nil:NilClass (NoMethodError)</p>
<p>This patch adds a default value of an empty array to the hash returned by Enumerable#group_by, so the script above will work:</p>
<p>$ ./ruby -I.:lib test_group_by.rb<br>
Fixnums: 3<br>
Strings: 2<br>
Arrays: 0</p> Ruby master - Bug #4746 (Closed): Documentation for bigdecimal/utilhttps://bugs.ruby-lang.org/issues/47462011-05-20T11:55:54Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>This patch adds documentation for the methods in bigdecimal/util. Additionally, I removed some comments at the top that were incorrectly applied elsewhere as documentation for the Float class.</p> Ruby master - Bug #4715 (Closed): Add some basic tests for Singletonhttps://bugs.ruby-lang.org/issues/47152011-05-17T07:50:50Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>Per the request over here: <a href="http://redmine.ruby-lang.org/issues/4709" class="external">http://redmine.ruby-lang.org/issues/4709</a></p>
<p>I've added some basic tests for Singleton after removing some example code that seemed to function as tests.</p> Ruby master - Bug #4709 (Closed): Revise documentation for Singletonhttps://bugs.ruby-lang.org/issues/47092011-05-16T17:10:08Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>Singleton seemed to be light on documentation, and it included some non-working example code that seemed to function as documentation and tests. In addition, a few classes and methods in the example code were picked up by Rdoc.</p>
<p>The first patch:</p>
<ul>
<li>Removes the example code.</li>
<li>Revises the documentation.</li>
</ul>
<p>The second patch:</p>
<ul>
<li>Adds some basic tests for Singleton.</li>
</ul> Ruby master - Bug #4702 (Closed): Some documentation for Digesthttps://bugs.ruby-lang.org/issues/47022011-05-16T11:34:17Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>Some of the methods in the Digest family were undocumented or badly formatted. This patch adds a little polish.</p>
<p>These docs could probably stand to be restructured, but this takes care of the obvious bad spots.</p> Ruby master - Bug #4701 (Closed): Hide some internal constants of Timeout from rdochttps://bugs.ruby-lang.org/issues/47012011-05-16T11:31:14Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>Timeout uses some constants to perform some of its voodoo with backtraces. These don't appear to be useful outside of Timeout, so I added :nodoc: to them.</p> Ruby master - Bug #4665 (Closed): Add nodoc comments for Set methodshttps://bugs.ruby-lang.org/issues/46652011-05-11T11:38:23Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>Set#flatten_merge and Set#do_with_enum are called internally by other Set methods. Add nodoc comments to them so they don't show up in the list of undocumented things.</p> Backport191 - Backport #3309 (Closed): net/http calls leak memory and file handles in windowshttps://bugs.ruby-lang.org/issues/33092010-05-18T09:45:28Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>=begin<br>
net/http calls leak memory and file handles in windows, and I've created a minimal script that demonstrates this.</p>
<p>When running the script, in between when the "before" and "after" lines are printed, Windows' Task Manager will show an increase in the Handles and Mem Usage columns. The amount of increase depends on the version of ruby used.</p>
<p>I've tested this on Windows XP with these versions of ruby:<br>
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]<br>
ruby 1.9.1p424 (2010-05-03 revision 27598) [i386-mingw32]<br>
ruby 1.9.3dev (2010-05-18 trunk 27874) [i386-mingw32]</p>
<p>More discussion of this issue occurred on the RubyInstaller mailing list in this thread:<br>
<a href="http://groups.google.com/group/rubyinstaller/browse_frm/thread/6bc9871f4a9f079" class="external">http://groups.google.com/group/rubyinstaller/browse_frm/thread/6bc9871f4a9f079</a><br>
=end</p> Ruby master - Bug #2992 (Closed): File operations leak file handles in Windows XPhttps://bugs.ruby-lang.org/issues/29922010-03-21T05:34:05Zphiggins (Pete Higgins)pete@peterhiggins.org
<p>=begin<br>
Various operations on files leak file handles in Windows XP. In the two attached scripts, Task Manager will report ~30 open file handles for the ruby process at the first gets, then ~230 at the second gets.</p>
<p>This has only been reproducible in Windows XP. This behavior is not seen in Windows Vista or 7.</p>
<p>More discussion of this issue occurred on the RubyInstaller mailing list in this thread:<br>
<a href="http://groups.google.com/group/rubyinstaller/browse_thread/thread/85ddec7241b4f0f7" class="external">http://groups.google.com/group/rubyinstaller/browse_thread/thread/85ddec7241b4f0f7</a><br>
=end</p>