Rails 2.1 RC1

Updated Instiki to Rails 2.1 RC1 (aka 2.0.991).
This commit is contained in:
Jacques Distler 2008-05-17 23:22:34 -05:00
parent 14afed5893
commit 5292899c9a
971 changed files with 46318 additions and 17450 deletions

View file

@ -13,20 +13,21 @@ module ActionController
def initialize(script_path)
@quiet = false
define_run_method(File.read(script_path))
define_run_method(script_path)
reset!
end
def benchmark(n)
@quiet = true
print ' '
result = Benchmark.realtime do
n.times do |i|
run
print i % 10 == 0 ? 'x' : '.'
$stdout.flush
print_progress(i)
end
end
puts
result
ensure
@ -38,8 +39,26 @@ module ActionController
end
private
def define_run_method(script)
instance_eval "def run; #{script}; end", __FILE__, __LINE__
def define_run_method(script_path)
script = File.read(script_path)
source = <<-end_source
def run
#{script}
old_request_count = request_count
reset!
self.request_count = old_request_count
end
end_source
instance_eval source, script_path, 1
end
def print_progress(i)
print "\n " if i % 60 == 0
print ' ' if i % 10 == 0
print '.'
$stdout.flush
end
end
@ -98,8 +117,9 @@ module ActionController
OptionParser.new do |opt|
opt.banner = "USAGE: #{$0} [options] [session script path]"
opt.on('-n', '--times [0000]', 'How many requests to process. Defaults to 100.') { |v| options[:n] = v.to_i }
opt.on('-n', '--times [100]', 'How many requests to process. Defaults to 100.') { |v| options[:n] = v.to_i if v }
opt.on('-b', '--benchmark', 'Benchmark instead of profiling') { |v| options[:benchmark] = v }
opt.on('-m', '--measure [mode]', 'Which ruby-prof measure mode to use: process_time, wall_time, cpu_time, allocations, or memory. Defaults to process_time.') { |v| options[:measure] = v }
opt.on('--open [CMD]', 'Command to open profile results. Defaults to "open %s &"') { |v| options[:open] = v }
opt.on('-h', '--help', 'Show this help') { puts opt; exit }
@ -117,7 +137,9 @@ module ActionController
def load_ruby_prof
begin
require 'ruby-prof'
#RubyProf.measure_mode = RubyProf::ALLOCATED_OBJECTS
if mode = options[:measure]
RubyProf.measure_mode = RubyProf.const_get(mode.upcase)
end
rescue LoadError
abort '`gem install ruby-prof` to use the profiler'
end