Class: RailsApiBenchmark::Core

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/rails_api_benchmark/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #logger

Constructor Details

#initializeCore

Returns a new instance of Core.



11
12
13
# File 'lib/rails_api_benchmark/core.rb', line 11

def initialize
  @config = RailsApiBenchmark.config
end

Class Method Details

.runObject



7
8
9
# File 'lib/rails_api_benchmark/core.rb', line 7

def self.run
  new.run
end

Instance Method Details

#create_indexObject



33
34
35
36
37
38
# File 'lib/rails_api_benchmark/core.rb', line 33

def create_index
  view = Views::IndexMarkdown.new(@config.routes)
  File.open(File.join(@config.results_folder, view.file_name), 'w') do |file|
    file << view.render
  end
end

#init_filesObject



29
30
31
# File 'lib/rails_api_benchmark/core.rb', line 29

def init_files
  FileUtils.mkdir_p(@config.results_folder)
end

#runObject



15
16
17
18
19
20
21
22
23
# File 'lib/rails_api_benchmark/core.rb', line 15

def run
  init_files
  @config.routes.each do |route|
    e = Endpoint.new(route)
    res = e.run_benchmark
    write_results(e, res)
  end
  create_index
end

#write_results(endpoint, results) ⇒ Object



25
26
27
# File 'lib/rails_api_benchmark/core.rb', line 25

def write_results(endpoint, results)
  Renderer.new(endpoint, results).process
end