Skip to content

Instantly share code, notes, and snippets.

@rdp
Created June 10, 2010 14:53
Show Gist options
  • Select an option

  • Save rdp/433110 to your computer and use it in GitHub Desktop.

Select an option

Save rdp/433110 to your computer and use it in GitHub Desktop.
patch to the RBS to make it use native driver for the benchmarks where available, instead of the just "ruby"
diff --git a/rakelib/bench.rake b/rakelib/bench.rake
index faa4a5a..81c1386 100644
--- a/rakelib/bench.rake
+++ b/rakelib/bench.rake
@@ -6,6 +6,7 @@
# updates are done manually to ensure stability.
#
# see utils/README for more information
+require 'rbconfig'
BASEDIR = File.expand_path(File.dirname(__FILE__) + "/..")
MONITOR = BASEDIR + "/utils/monitor.rb"
@@ -14,17 +15,21 @@ RBS_DIR = BASEDIR + "/benchmarks"
RESULTS_DIR = BASEDIR + "/results"
RBS_RESULTS_DIR = RESULTS_DIR + "/rbs"
WEB_DIR = RESULTS_DIR + "/web"
-
ITERATIONS = (ENV['ITERATIONS'] || 5).to_i
TIMEOUT = (ENV['TIMEOUT'] || 300).to_i
METER_MEMORY = ENV['METER_MEMORY'] || 'yes'
-VM = ENV['VM'] || "ruby"
+config = RbConfig::CONFIG
+RUBY_BIN = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
+VM = ENV['VM'] || RUBY_BIN
+puts VM
def command(name)
- # note that we use ruby here
- # so that we'll be using a "stable" ruby for driving the monitor
- # thus the test candidate ruby will only be running the test.
- "ruby #{MONITOR} #{TIMEOUT} '#{VM}' #{RUNNER} #{name} #{ITERATIONS} #{report} #{METER_MEMORY}"
+ # note that if your "test candidate" ruby cannot run the monitor script, then run the benchmark
+ # using the rake of a "stable" ruby, and use the VM parameter.
+
+ a = "#{RUBY_BIN} #{MONITOR} #{TIMEOUT} '#{VM}' #{RUNNER} #{name} #{ITERATIONS} #{report} #{METER_MEMORY}"
+ puts a
+ a
end
# Cache the name so it is only generated once during an invocation.
diff --git a/utils/monitor.rb b/utils/monitor.rb
index 5611d55..123b57e 100644
--- a/utils/monitor.rb
+++ b/utils/monitor.rb
@@ -8,7 +8,9 @@ null = "/dev/null"
require 'rbconfig'
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ # jruby compat.
- timeout = "ruby " + File.dirname(__FILE__) + "/timeout2.rb"
+ config = RbConfig::CONFIG
+ ruby_bin = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
+ timeout = "\"#{ruby_bin}\" " + File.dirname(__FILE__) + "/timeout2.rb"
null = "NUL"
end
diff --git a/utils/timeout2.rb b/utils/timeout2.rb
index 61f7033..357c099 100644
--- a/utils/timeout2.rb
+++ b/utils/timeout2.rb
@@ -17,5 +17,8 @@ begin
}
rescue Timeout::Error
puts 'timed out'
- Process.kill "KILL", out.pid # if this fails it may have died right then
+ Process.kill "KILL", out.pid # if this fails it may have already terminate
+rescue NotImplementedError => e
+ # jruby ... http://jira.codehaus.org/browse/JRUBY-4354
+ puts e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment