benchmark/run.rb in manveru-ramaze-2009.04.22 vs benchmark/run.rb in manveru-ramaze-2009.05

- old
+ new

@@ -142,12 +142,12 @@ end end end attr_accessor :requests, :adapters, :port, :log, :display_code, :target - attr_accessor :concurrent, :paths, :benchmarker, :informer, :sessions - attr_accessor :show_log, :ignored_tags, :formats + attr_accessor :concurrent, :paths, :benchmarker, :informer + attr_accessor :mode, :show_log, :formats def initialize() @adapters = [:webrick] @port = rand(32768-1)+32768 @requests = 100 @@ -155,14 +155,13 @@ @signal = 'SIGKILL' @host = "127.0.0.1" @paths = ["/"] @target = /.+/ @informer = true - @sessions = true - @ignored_tags = [:debug, :dev] @formats = ["text"] @writers = [] + @mode = :live yield self end def start # setup writers @@ -173,12 +172,12 @@ when "text" ; @writers << BasicWriter.new end end # benchmarks - __DIR__ = File.expand_path(File.dirname(__FILE__)) - Dir[__DIR__('suite/*.rb')].each do |filename| + glob = File.expand_path('../suite/*.rb', __FILE__) + Dir.glob(glob) do |filename| @adapters.each do |adapter| @paths.each do |path| benchmark(filename, adapter, path) if @target.match(filename) end end @@ -197,11 +196,10 @@ l :Adapter, adapter l :Requests, @requests l :Concurrent, @concurrent l :Path, path l :Informer, @informer - l :Sessions, @sessions if @display_code l :Code, "<code ruby>\n#{File.read(filename)}\n</code>\n\n" end # real benchmark @@ -246,21 +244,21 @@ # startup def ramaze(filename, adapter) pid = fork do begin - require filename - Ramaze::Log.ignored_tags = @ignored_tags + require 'ramaze' + Ramaze.options.mode = @mode if @informer unless @show_log - Ramaze::Log.loggers = [Ramaze::Logging::Logger::Informer.new("/dev/null")] + require 'ramaze/log/informer' + Ramaze::Log.loggers = [Ramaze::Logger::Informer.new("/dev/null")] end else Ramaze::Log.loggers = [] end - Ramaze::Global.sessions = @sessions - Ramaze::Global.sourcereload = false + require filename Ramaze.start :adapter => adapter, :port => @port rescue LoadError => ex; l :Error, ex; end end yield pid if wait_to_startup @@ -322,24 +320,19 @@ opt.on('--paths PATHS', '[/] Specify request paths') do |paths| bm.paths = paths.split(",") end + opt.on('--mode MODE', '[live] Ramaze mode') do |mode| + bm.mode = mode.to_sym + end + opt.on('--no-informer', 'Disable informer') do bm.informer = false end - opt.on('--ignored-tags TAGS', - '[debug,dev] Specify ignored tags for Ramaze::Log') do |tags| - bm.ignored_tags = tags.split(",").map{|e| e.to_sym } - end - opt.on('--show-log', 'Show log') do bm.show_log = true - end - - opt.on('--no-sessions', 'Disable sessions') do - bm.sessions = false end opt.on('--target REGEXP', '[/.+/] Specify benchmark scripts to measure') do |name| bm.target = Regexp.compile(name)