Class: RailsApiBenchmark::Core
- Inherits:
-
Object
- Object
- RailsApiBenchmark::Core
- Includes:
- Logging
- Defined in:
- lib/rails_api_benchmark/core.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_index ⇒ Object
- #init_files ⇒ Object
-
#initialize ⇒ Core
constructor
A new instance of Core.
- #run ⇒ Object
- #write_results(endpoint, results) ⇒ Object
Methods included from Logging
Constructor Details
#initialize ⇒ Core
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
.run ⇒ Object
7 8 9 |
# File 'lib/rails_api_benchmark/core.rb', line 7 def self.run new.run end |
Instance Method Details
#create_index ⇒ Object
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_files ⇒ Object
29 30 31 |
# File 'lib/rails_api_benchmark/core.rb', line 29 def init_files FileUtils.mkdir_p(@config.results_folder) end |
#run ⇒ Object
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 |