Rails 2.1
Update to Rails 2.1 final.
This commit is contained in:
parent
fd554cce90
commit
516d6dfac0
257 changed files with 4058 additions and 1933 deletions
|
@ -17,13 +17,13 @@ module ActionController
|
|||
reset!
|
||||
end
|
||||
|
||||
def benchmark(n)
|
||||
def benchmark(n, profiling = false)
|
||||
@quiet = true
|
||||
print ' '
|
||||
|
||||
result = Benchmark.realtime do
|
||||
n.times do |i|
|
||||
run
|
||||
run(profiling)
|
||||
print_progress(i)
|
||||
end
|
||||
end
|
||||
|
@ -43,8 +43,15 @@ module ActionController
|
|||
script = File.read(script_path)
|
||||
|
||||
source = <<-end_source
|
||||
def run
|
||||
#{script}
|
||||
def run(profiling = false)
|
||||
if profiling
|
||||
RubyProf.resume do
|
||||
#{script}
|
||||
end
|
||||
else
|
||||
#{script}
|
||||
end
|
||||
|
||||
old_request_count = request_count
|
||||
reset!
|
||||
self.request_count = old_request_count
|
||||
|
@ -91,21 +98,22 @@ module ActionController
|
|||
def profile(sandbox)
|
||||
load_ruby_prof
|
||||
|
||||
results = RubyProf.profile { benchmark(sandbox) }
|
||||
benchmark(sandbox, true)
|
||||
results = RubyProf.stop
|
||||
|
||||
show_profile_results results
|
||||
results
|
||||
end
|
||||
|
||||
def benchmark(sandbox)
|
||||
def benchmark(sandbox, profiling = false)
|
||||
sandbox.request_count = 0
|
||||
elapsed = sandbox.benchmark(options[:n]).to_f
|
||||
elapsed = sandbox.benchmark(options[:n], profiling).to_f
|
||||
count = sandbox.request_count.to_i
|
||||
puts '%.2f sec, %d requests, %d req/sec' % [elapsed, count, count / elapsed]
|
||||
end
|
||||
|
||||
def warmup(sandbox)
|
||||
Benchmark.realtime { sandbox.run }
|
||||
Benchmark.realtime { sandbox.run(false) }
|
||||
end
|
||||
|
||||
def default_options
|
||||
|
@ -136,6 +144,7 @@ module ActionController
|
|||
protected
|
||||
def load_ruby_prof
|
||||
begin
|
||||
gem 'ruby-prof', '>= 0.6.1'
|
||||
require 'ruby-prof'
|
||||
if mode = options[:measure]
|
||||
RubyProf.measure_mode = RubyProf.const_get(mode.upcase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue