Module: Puma::Benchmark

Defined in:
lib/puma/benchmark.rb,
lib/puma/benchmark/core.rb,
lib/puma/benchmark/version.rb,
lib/puma/benchmark/print_result.rb

Defined Under Namespace

Classes: Core, Error, PrintResult

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.parse(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/puma/benchmark.rb', line 19

def self.parse(options)
  params = {}
  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: puma-benchmark [options]"

    opts.on("-b", "--base_url [BASE_URL]", URI,  "Application base url for
                   benchmarking, default: http://localhost:3000")

    opts.on("-a", "--api API", "API for benchmarking, example: /homes.json")

    opts.on("-e", "--environment", "default: production")
    
    opts.on("-t", "--threads [Max Thread]", "Max thread to be used per worker, default: 4")

    opts.on("-w", "--workers [Max Worker]", "Max worker to be used for benchmarking, default: 4")

    opts.on("-d", "--duration [Duration]", "Duration for each test (in seconds), default: 30")

    opts.on("-h", "--help", "Prints this help") do
      puts opts
      exit
    end
  end.parse!(into: params)

  run(params)
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/puma/benchmark.rb', line 11

def self.run(params)
  if params[:api]
    Puma::Benchmark::Core.new(params).run
  else
    puts "API parameter is mandatory, try puma-benchmark -h"
  end
end