Added ability to add benchmark results from hardware page
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2024-02-09 13:57:01 -05:00
parent 5628c69d66
commit 1e0cd49cf8
4 changed files with 48 additions and 7 deletions

View File

@ -8,4 +8,14 @@ module Helpers
return dt.strftime('%B %d, %Y @ %I:%M:%S %p %Z')
end
def average_array(arr, decimals = 1)
sum = 0
arr.each do |i|
sum += i
end
return (sum / arr.length).round(decimals)
end
end

View File

@ -5,4 +5,18 @@ class Hardware < Sequel::Model(:hardware)
one_to_many :results
def bench_results()
br = Hash.new()
self.results.each do |r|
unless br.key?(r.benchmark.name)
br[r.benchmark.name.to_s] = []
end
br[r.benchmark.name.to_s].push(r.avg_score)
end
return br
end
end

View File

@ -4,10 +4,10 @@
class Result < Sequel::Model
many_to_one :hardware
many_to_one :benchmarks
many_to_one :benchmark
def formatted_score
return @score
return @avg_score
end
end

View File

@ -59,10 +59,27 @@
<h4>Benchmark results involving this hardware:</h4>
<ul>
<% hardware.results().each do |r| %>
<li><%= r.avg_score %></li>
<% end %>
</ul>
<table>
<thead>
<th>Benchmark name</th>
<th>Scoring type</th>
<th># results</th>
<th>Average</th>
<th>Minimum</th>
<th>Maximum</th>
</thead>
<tbody>
<% hardware.bench_results().each do |k, r| %>
<tr>
<td><%= k %></td>
<td>N/a</td>
<td><%= r.length %></td>
<td><%= average_array(r) %></td>
<td>N/a</td>
<td>N/a</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>