Class: RailsApiBenchmark::Configuration
- Inherits:
-
Object
- Object
- RailsApiBenchmark::Configuration
- Defined in:
- lib/rails_api_benchmark.rb
Instance Attribute Summary collapse
-
#auth_header ⇒ Object
Returns the value of attribute auth_header.
-
#bench_cmd ⇒ Object
Returns the value of attribute bench_cmd.
-
#concurrency ⇒ Object
Returns the value of attribute concurrency.
-
#curl_cmd ⇒ Object
Returns the value of attribute curl_cmd.
-
#env_vars ⇒ Object
Returns the value of attribute env_vars.
-
#host ⇒ Object
Returns the value of attribute host.
-
#nb_requests ⇒ Object
Returns the value of attribute nb_requests.
-
#regexps ⇒ Object
Returns the value of attribute regexps.
-
#results_folder ⇒ Object
Returns the value of attribute results_folder.
-
#routes ⇒ Object
Returns the value of attribute routes.
-
#server_cmd ⇒ Object
Returns the value of attribute server_cmd.
-
#summary ⇒ Object
Returns the value of attribute summary.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize ⇒ Configuration
constructor
Default values, INSANE.
Constructor Details
#initialize ⇒ Configuration
Default values, INSANE. Must be refactored Maybe create a yaml or json file to import for default values
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 45 46 47 48 |
# 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 |
Instance Attribute Details
#auth_header ⇒ Object
Returns the value of attribute auth_header.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def auth_header @auth_header end |
#bench_cmd ⇒ Object
Returns the value of attribute bench_cmd.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def bench_cmd @bench_cmd end |
#concurrency ⇒ Object
Returns the value of attribute concurrency.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def concurrency @concurrency end |
#curl_cmd ⇒ Object
Returns the value of attribute curl_cmd.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def curl_cmd @curl_cmd end |
#env_vars ⇒ Object
Returns the value of attribute env_vars.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def env_vars @env_vars end |
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def host @host end |
#nb_requests ⇒ Object
Returns the value of attribute nb_requests.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def nb_requests @nb_requests end |
#regexps ⇒ Object
Returns the value of attribute regexps.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def regexps @regexps end |
#results_folder ⇒ Object
Returns the value of attribute results_folder.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def results_folder @results_folder end |
#routes ⇒ Object
Returns the value of attribute routes.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def routes @routes end |
#server_cmd ⇒ Object
Returns the value of attribute server_cmd.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def server_cmd @server_cmd end |
#summary ⇒ Object
Returns the value of attribute summary.
13 14 15 |
# File 'lib/rails_api_benchmark.rb', line 13 def summary @summary end |
Instance Method Details
#all ⇒ Object
50 51 52 53 54 55 |
# 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 |