# == Schema Information
#
# Table name: benchmark_results
#
# id :integer not null, primary key
# benchmark_info_id :integer
# created_at :datetime
# updated_at :datetime
# benchmark_batch_id :integer
#
class BenchmarkResult < ActiveRecord::Base
belongs_to :benchmark_info, inverse_of: :benchmark_results
belongs_to :benchmark_batch, inverse_of: :benchmark_results
has_many :benchmark_durations, dependent: :destroy, inverse_of: :benchmark_result
def average_duration
sum = benchmark_durations.inject(0) { |acc, val| acc += val.duration }
sum / benchmark_durations.size
end
def min_duration
benchmark_durations.map { |duration| duration.duration }.min
end
def max_duration
benchmark_durations.map { |duration| duration.duration }.max
end
end