class BigBench::Fragment::Fragment

Attributes

benchmark[RW]
method[RW]
options[RW]
path[RW]
uri[RW]

Public Class Methods

new(benchmark, path, method, options = {}) click to toggle source
# File lib/bigbench/fragment.rb, line 42
def initialize benchmark, path, method, options = {}
  @benchmark, @path, @method, @options, @request_options = benchmark, path, method, options, {}
  @uri = URI(@benchmark.uri.to_s + @path)
  configure_options
end

Public Instance Methods

run!() click to toggle source

Initiates the request in the context of a Net::HTTP.start block

# File lib/bigbench/fragment.rb, line 49
def run!
  EventMachine::HttpRequest.new(@uri.to_s).send(@method, @request_options)
end
track!(start, stop, http) click to toggle source

Adds the current tracking result as a hash to the benchmark’s tracker

# File lib/bigbench/fragment.rb, line 54
def track!(start, stop, http)
  @benchmark.tracker.track(
    {
      :elapsed    => (stop - benchmark.start).to_f,
      :start      => start.to_f,
      :stop       => stop.to_f,
      :duration   => (stop - start).to_milliseconds,
      :benchmark  => @benchmark.name,
      :url        => @uri.to_s,
      :path       => @uri.request_uri,
      :method     => @method,
      :status     => (s = http.response_header.status.to_i; s > 0 ? s : 404)
    }
  )
end