[MacRuby-devel] [PATCH] perf/run.rb patch for ignoring ERROR

Jordan Breeding jordan.breeding at me.com
Wed May 26 14:39:08 PDT 2010


Currently ERROR is not thrown out of the results before they are tested to see which is best, this means that ERROR is actually considered the winner after running .to_f on it.

My current patch probably doesn't handle the case of each of the rubies being tested all having ERROR, but it does work if at least one real value was returned. This patch also changes it so that if you are testing a large number of ruby installations (4 or more) on a wide terminal window the "----" underline will cover all of the names instead of stopping at 80 characters.

diff --git a/perf/run.rb b/perf/run.rb
index 14af044..7279136 100644
--- a/perf/run.rb
+++ b/perf/run.rb
@@ -31,9 +31,10 @@ end
 
 rubies_names = rubies.map { |x| `#{x} -v`.scan(/^\w+\s+[^\s]+/)[0] }
 
-print 'Name'.ljust(20)
-rubies_names.each { |x| print x.ljust(20) }
-puts '', '-' * 80
+header_string = 'Name'.ljust(20)
+rubies_names.each { |x| header_string += x.ljust(20) }
+print header_string
+puts '', '-' * header_string.length
 
 booter = File.join(cwd, 'boot.rb')
 perf_files.each do |file, suite|
@@ -53,7 +54,7 @@ perf_files.each do |file, suite|
     print "#{prefix}:#{title}".ljust(20)
     winner = nil
     if res.size > 1
-      winner = res.sort { |a, b| a[:best].to_f <=> b[:best].to_f }.first[:best]
+      winner = res.reject { |a| a[:best] == 'ERROR' }.sort { |a, b| a[:best].to_f <=> b[:best].to_f }.first[:best]
     end
     res.each do |rb|
       best = rb[:best]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3842 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100526/1ae23a6b/attachment-0001.bin>


More information about the MacRuby-devel mailing list