Class: Performance::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/performance_report.rb

Instance Method Summary collapse

Constructor Details

#initialize(run_time: DEFAULT_RUN_TIME, warmup: DEFAULT_WARMUP, items: DEFAULT_ITEMS) ⇒ Report

Returns a new instance of Report.



178
179
180
181
182
183
184
# File 'lib/tasks/performance_report.rb', line 178

def initialize(run_time: DEFAULT_RUN_TIME, warmup: DEFAULT_WARMUP,
               items: DEFAULT_ITEMS)
  @run_time = run_time
  @warmup = warmup
  @items = items
  @results = {}
end

Instance Method Details

#as_jsonObject



196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/tasks/performance_report.rb', line 196

def as_json
  {
    report_id: REPORT_ID,
    ruby_version: RUBY_VERSION,
    platform: RUBY_PLATFORM,
    run_time: @run_time,
    warmup: @warmup,
    items: @items,
    sax_available: SAX_AVAILABLE,
    benchmarks: @results,
  }
end

#run_allObject



186
187
188
189
190
191
192
193
194
# File 'lib/tasks/performance_report.rb', line 186

def run_all
  BENCHMARKS.each do |method, meta|
    next if method.to_s.start_with?("xml_parse_sax") && !SAX_AVAILABLE

    label = "#{meta[:category]}: #{meta[:name]}"
    @results[label] = run_benchmark(method)
  end
  @results
end