Class: HanselCore::Hansel
- Inherits:
-
Object
- Object
- HanselCore::Hansel
- Includes:
- Formatting, Httperf, JobQueue
- Defined in:
- lib/hansel/hansel.rb
Overview
Class wrapper over httperf.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #config_path ⇒ Object
-
#initialize(options = OpenStruct.new {}) ⇒ Hansel
constructor
A new instance of Hansel.
-
#output ⇒ Object
Output the results based on the requested output format.
- #output_dir ⇒ Object
- #register ⇒ Object
-
#run ⇒ Object
Run httperf from low_rate to high_rate, stepping by rate_step.
- #run_server ⇒ Object
- #status(text) ⇒ Object
Methods included from JobQueue
#jobs, #load_job_queue, #pop_job, #push_job
Methods included from Httperf
Methods included from Formatting
#csv_formatter, #formatted_output, #octave_formatter, #output_filename, #yaml_formatter
Constructor Details
#initialize(options = OpenStruct.new {}) ⇒ Hansel
Returns a new instance of Hansel.
12 13 14 15 16 17 |
# File 'lib/hansel/hansel.rb', line 12 def initialize = OpenStruct.new {} @options = @results = [] @current_rate = nil @jobs = [] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/hansel/hansel.rb', line 10 def @options end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
10 11 12 |
# File 'lib/hansel/hansel.rb', line 10 def results @results end |
Instance Method Details
#config_path ⇒ Object
19 20 21 22 23 |
# File 'lib/hansel/hansel.rb', line 19 def config_path @config_path ||= File.join [ENV['HOME'], '.hansel'] FileUtils.mkdir_p @config_path unless File.exists? @config_path @config_path end |
#output ⇒ Object
Output the results based on the requested output format
38 39 40 41 42 43 44 45 |
# File 'lib/hansel/hansel.rb', line 38 def output opts = if opts.format FileUtils.mkdir_p opts.output_dir formatted_output end @results.clear end |
#output_dir ⇒ Object
25 26 27 28 |
# File 'lib/hansel/hansel.rb', line 25 def output_dir @output_dir ||= File.join [ENV['HOME'], 'hansel_output'] @output_dir end |
#register ⇒ Object
30 31 32 33 |
# File 'lib/hansel/hansel.rb', line 30 def register response = Typhoeus::Request.get .master @token = JSON.parse(response.body)['token'] end |
#run ⇒ Object
Run httperf from low_rate to high_rate, stepping by rate_step
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hansel/hansel.rb', line 54 def run while @jobs.length > 0 do # do a warm up run first with the highest connection rate @current_job = @jobs.pop @current_rate = @current_job.high_rate.to_i httperf true (@current_job.low_rate.to_i..@current_job.high_rate.to_i). step(@current_job.rate_step.to_i) do |rate| @current_rate = rate httperf end output end end |
#run_server ⇒ Object
70 71 72 73 |
# File 'lib/hansel/hansel.rb', line 70 def run_server HanselSlaveServer.hansel = self HanselSlaveServer.run! :host => 'localhost', :port => 4000 end |
#status(text) ⇒ Object
47 48 49 |
# File 'lib/hansel/hansel.rb', line 47 def status text puts text if .verbose end |