A fragment represents a single http request inside a benchmark. It is executed by the benchmark and resides inside the benchmark block in the test reciepts:
benchmark "index page" => "http://localhost:3000" do # Fragments end
Possible fragment types are the HTTP verbs, like GET, POST, PUT and DELETE. They look like this:
get "/" post "/login/new", { :name => "a name", :password => "secret" } put "/books", { :name => "A Book title", :rating => 30.4 } delete "/books/5"
Performs a DELETE request to the given url, e.g.
delete "/books/5", { :user => "some@sample.com", :password => "secret" }
# File lib/bigbench/fragment.rb, line 99 def self.delete(path, params = {}) @fragments << Fragment.new(@benchmark, path, :delete, params) end
Performs a GET request to the given url, e.g.
get "/some/page"
# File lib/bigbench/fragment.rb, line 75 def self.get(path) @fragments << Fragment.new(@benchmark, path, :get, {}) end
Evaluates a benchmark block full of puts and gets and returns an array of fully configured fragments for it
# File lib/bigbench/fragment.rb, line 104 def self.parse(benchmark, &block) reset! return [] if block.nil? @benchmark = benchmark module_exec(&block) @fragments end
Performs a POST request to the given url, e.g.
post "/login", { :user => "some@sample.com", :password => "secret" }
# File lib/bigbench/fragment.rb, line 83 def self.post(path, params = {}) @fragments << Fragment.new(@benchmark, path, :post, params) end
Performs a PUT request to the given url, e.g.
put "/books", { :book => "Some book content" }
# File lib/bigbench/fragment.rb, line 91 def self.put(path, params = {}) @fragments << Fragment.new(@benchmark, path, :put, params) end
Reset all fragments
# File lib/bigbench/fragment.rb, line 113 def self.reset! @benchmark = nil @fragments = [] end