class RailsApiBenchmark::Core

Public Class Methods

new() click to toggle source
# File lib/rails_api_benchmark/core.rb, line 11
def initialize
  @config = RailsApiBenchmark.config
  @resultset = ResultSet.new
  init_files
  write_index
end
run() click to toggle source
# File lib/rails_api_benchmark/core.rb, line 7
def self.run
  new.run
end

Public Instance Methods

run() click to toggle source
# File lib/rails_api_benchmark/core.rb, line 18
def run
  @config.routes.each do |route|
    e = Endpoint.new(route)
    res = e.run_benchmark
    @resultset.add(e, res)
  end
  @resultset.compute_relative_speed
  write_results
end

Private Instance Methods

init_files() click to toggle source
# File lib/rails_api_benchmark/core.rb, line 38
def init_files
  FileUtils.mkdir_p(@config.results_folder)
end
write_index() click to toggle source
# File lib/rails_api_benchmark/core.rb, line 42
def write_index
  Views::IndexMarkdown.new.write
end
write_results() click to toggle source
# File lib/rails_api_benchmark/core.rb, line 30
def write_results
  Views::SummaryMarkdown.new(@resultset).write if @config.summary

  @resultset.each_result do |endpoint, results|
    Renderer.new(endpoint, results).process
  end
end