Method: Waw::Commands::ProfileCommand#__run

Defined in:
lib/waw/commands/profile_command.rb

#__run(requester_file, arguments) ⇒ Object

Runs the sub-class defined command



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/waw/commands/profile_command.rb', line 44

def __run(requester_file, arguments)
  require 'waw/wspec/browser'
  
  # Start the server first
  thread, waw_kernel = ::Waw::Commands::StartCommand.new.waw_start(requester_file, verbose)
  visited, browser, location = {}, ::Waw::WSpec::Browser.new, waw_kernel.config.web_base
  
  # Launch the visit
  t1 = Time.now
  visit(browser, location, visited)
  t2 = Time.now
  
  # Stop the server now
  thread.exit
  
  # Show statistics
  req_by_sec = visited.size.to_f/(t2-t1)
  avg_by_sec = (t2-t1)/visited.size
  
  puts "#{visited.size} pages visited in #{t2-t1} seconds (#{req_by_sec} req./sec., #{avg_by_sec} sec./req.)"
rescue Interrupt => ex
  info "waw-profile stopping now... ciao!" if verbose
end