Sha256: a58b3f79145fc662943d85ff39b43a3dbc48f1d8054d6f29e518b440eb9fdfe6

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
require 'wbench'
require 'optparse'

options = {}.tap do |options|
  OptionParser.new do |opts|
    opts.version = WBench::VERSION
    opts.banner  = 'Usage: wbench url [options]'

    opts.separator ""
    opts.separator "Options:"

    opts.on("-l", "--loops [LOOPS]", Integer, "Set number of loops (default: #{WBench::DEFAULT_LOOPS})") do |loops|
      options[:loops] = loops
    end

    opts.on("-b", "--browser [BROWSER]", "Set the web browser, chrome and firefox are available (default: #{WBench::DEFAULT_BROWSER})") do |browser|
      options[:browser] = browser
    end

    opts.on("-u", "--user-agent [USER AGENT]", "Set the user-agent (default: browsers' default user-agent value)") do |user_agent|
      options[:user_agent] = user_agent
    end

    opts.on("-nc", "--no-color", "Disable color output") do
      options[:color_output] = false
    end

    opts.on("-c", "--cookie [COOKIE]", "Set the cookie (default: browsers' default cookie value)") do |cookie|
      options[:cookie] = cookie
    end
  end.parse!
end

if options.has_key?(:color_output)
  WBench.color_output = options.delete(:color_output)
end

if url = ARGV[0]
  puts WBench::Benchmark.run(url, options)
else
  abort 'Please provide a URL to benchmark'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wbench-1.1.1 bin/wbench
wbench-1.1.0 bin/wbench