author | Marcel Hlopko <marcel.hlopko@gmail.com> |
Sat, 22 Jun 2013 15:02:47 +0200 | |
changeset 70 | e9c892b1c82b |
parent 68 | ea16cf625333 |
child 105 | 8293977e9a30 |
permissions | -rw-r--r-- |
44 | 1 |
# == Schema Information |
2 |
# |
|
3 |
# Table name: benchmark_results |
|
4 |
# |
|
5 |
# id :integer not null, primary key |
|
6 |
# benchmark_info_id :integer |
|
7 |
# language_implementation_id :integer |
|
65
a37ce193f555
add basic import support (text, file, push via POST)
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
44
diff
changeset
|
8 |
# performed_at :datetime |
44 | 9 |
# created_at :datetime |
10 |
# updated_at :datetime |
|
65
a37ce193f555
add basic import support (text, file, push via POST)
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
44
diff
changeset
|
11 |
# benchmark_batch_id :integer |
44 | 12 |
# |
13 |
||
14 |
class BenchmarkResult < ActiveRecord::Base |
|
15 |
||
16 |
belongs_to :benchmark_info, dependent: :destroy, inverse_of: :benchmark_results |
|
65
a37ce193f555
add basic import support (text, file, push via POST)
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
44
diff
changeset
|
17 |
belongs_to :benchmark_batch, dependent: :destroy, inverse_of: :benchmark_results |
44 | 18 |
has_many :benchmark_durations, inverse_of: :benchmark_result |
19 |
has_many :benchmark_parameters, inverse_of: :benchmark_result |
|
20 |
||
68 | 21 |
def average_duration |
22 |
sum = benchmark_durations.inject(0) { |acc, val| acc += val.duration } |
|
23 |
sum / benchmark_durations.size |
|
24 |
end |
|
25 |
||
70
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
26 |
def min_duration |
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
27 |
benchmark_durations.map { |duration| duration.duration }.min |
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
28 |
end |
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
29 |
|
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
30 |
def max_duration |
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
31 |
benchmark_durations.map { |duration| duration.duration }.max |
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
32 |
end |
e9c892b1c82b
nicer tables, useless graph removed
Marcel Hlopko <marcel.hlopko@gmail.com>
parents:
68
diff
changeset
|
33 |
|
44 | 34 |
end |