[macruby-changes] [4167] MacRuby/trunk/perf/run.rb

source_changes at macosforge.org source_changes at macosforge.org
Wed May 26 16:14:16 PDT 2010


Revision: 4167
          http://trac.macosforge.org/projects/ruby/changeset/4167
Author:   martinlagardette at apple.com
Date:     2010-05-26 16:14:14 -0700 (Wed, 26 May 2010)
Log Message:
-----------
Add a very basic usage text + apply patch by Jordan Breeding

Modified Paths:
--------------
    MacRuby/trunk/perf/run.rb

Modified: MacRuby/trunk/perf/run.rb
===================================================================
--- MacRuby/trunk/perf/run.rb	2010-05-26 22:00:53 UTC (rev 4166)
+++ MacRuby/trunk/perf/run.rb	2010-05-26 23:14:14 UTC (rev 4167)
@@ -1,11 +1,20 @@
 #!/usr/bin/ruby
 
+def usage
+  puts "ruby #{$0} [--rubies=...] [--iterations=n] [perf_suite, [perf_suite...]]"
+  exit 0
+end
+
+usage if ARGV.size < 1
+
 cwd = File.dirname(__FILE__)
 perf_files = []
 rubies = []
 n_iterations = 3
 ARGV.each do |arg|
-  if md = /--rubies=(.*)/.match(arg)
+  if arg.match(/--help/)
+    usage
+  elsif md = /--rubies=(.*)/.match(arg)
     rubies = md[1].split(/,/)
   elsif md = /--iterations=(.*)/.match(arg)
     n_iterations = md[1].to_i
@@ -31,9 +40,10 @@
 
 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 +63,9 @@
     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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100526/117aa74b/attachment.html>


More information about the macruby-changes mailing list