equal
deleted
inserted
replaced
|
1 class BenchmarkInfo < ActiveRecord::Base |
|
2 |
|
3 has_many :benchmark_results, dependent: :destroy, inverse_of: :benchmark_info |
|
4 |
|
5 validates_presence_of :name, :benchmark_class, :benchmark_selector |
|
6 |
|
7 def self.from_json(data) |
|
8 bench_info = BenchmarkInfo.find_by(name: data["name"]) |
|
9 unless bench_info |
|
10 bench_info = BenchmarkInfo.create!( |
|
11 name: data["name"], |
|
12 benchmark_class: data["class"], |
|
13 benchmark_selector: data["selector"], |
|
14 description: data["description"] |
|
15 ) |
|
16 end |
|
17 |
|
18 bench_info |
|
19 end |
|
20 |
|
21 def to_results_json_for_configuration(configuration) |
|
22 data = benchmark_results. |
|
23 includes(:benchmark_batch, :benchmark_durations). |
|
24 joins(:benchmark_batch). |
|
25 where("benchmark_batches.benchmark_configuration_id = ?", configuration.id). |
|
26 map(&:to_json) |
|
27 |
|
28 { name: name, data: data } |
|
29 end |
|
30 end |
|
31 |
1 # == Schema Information |
32 # == Schema Information |
2 # |
33 # |
3 # Table name: benchmark_infos |
34 # Table name: benchmark_infos |
4 # |
35 # |
5 # id :integer not null, primary key |
36 # id :integer not null, primary key |
9 # created_at :datetime |
40 # created_at :datetime |
10 # updated_at :datetime |
41 # updated_at :datetime |
11 # name :string(255) |
42 # name :string(255) |
12 # |
43 # |
13 |
44 |
14 class BenchmarkInfo < ActiveRecord::Base |
|
15 |
|
16 has_many :benchmark_results, dependent: :destroy, inverse_of: :benchmark_info |
|
17 |
|
18 validates_presence_of :name, :benchmark_class, :benchmark_selector |
|
19 |
|
20 def BenchmarkInfo.from_json(data) |
|
21 bench_info = BenchmarkInfo.where(name: data["name"]).first |
|
22 bench_info = BenchmarkInfo.create!( |
|
23 name: data["name"], |
|
24 benchmark_class: data["class"], |
|
25 benchmark_selector: data["selector"], |
|
26 description: data["description"] |
|
27 ) unless bench_info |
|
28 return bench_info |
|
29 |
|
30 end |
|
31 end |
|