class RailsApiBenchmark::Configuration

Attributes

auth_header[RW]
bench_cmd[RW]
concurrency[RW]
curl_cmd[RW]
env_vars[RW]
host[RW]
nb_requests[RW]
regexps[RW]
results_folder[RW]
routes[RW]
server_cmd[RW]
summary[RW]

Public Class Methods

new() click to toggle source

Default values, INSANE. Must be refactored Maybe create a yaml or json file to import for default values

# File lib/rails_api_benchmark.rb, line 19
def initialize
  self.concurrency = 2
  self.nb_requests = 1000
  self.server_cmd = 'bundle exec puma'
  self.bench_cmd = 'ab -n %{nb_requests} -c %{concurrency} -g plot.tsv' \
              ' -H "%{auth_header}" http://%{host}%{route}'
  self.curl_cmd = 'curl -H "%{auth_header}" http://%{host}%{route}'
  self.results_folder = 'benchmark'
  self.summary = true
  self.regexps = [
    {
      key: :response_time,
      name: 'Average time per request (ms)',
      regexp: /Time\s+per\s+request:\s+([0-9.]*).*\(mean\)/
    }, {
      key: :req_per_sec,
      name: 'Requests per second (#)',
      regexp: /Requests\s+per\s+second:\s+([0-9.]*).*\(mean\)/
    }
  ]
  self.env_vars = {
    'RAILS_MAX_THREADS' => '2',
    'RAILS_ENV' => 'production',
    'SSL_DISABLE' => 'true',
    'SECRET_KEY_BASE' => 'a1b2c3',
    'PORT' => '5000'
  }
  self.routes = []
  self.host = 'localhost:5000'
end

Public Instance Methods

all() click to toggle source
# File lib/rails_api_benchmark.rb, line 50
def all
  instance_variables.inject({}) do |h, v|
    var = v.to_s.sub('@', '')
    h.merge(var.to_sym => send(var))
  end
end