Compare commits
10 Commits
55e4f397f8
...
main
Author | SHA1 | Date | |
---|---|---|---|
bc5ae4962f | |||
ec2bf45a6e | |||
57163b10e4 | |||
25d394627d | |||
85dfdb163a | |||
b593ef7593 | |||
26698082f4 | |||
42a0b95015 | |||
5cc3b8f824 | |||
d59c75281e |
@ -1,6 +1,6 @@
|
|||||||
pipeline:
|
pipeline:
|
||||||
style:
|
style:
|
||||||
image: ruby:3.0
|
image: ruby:3.4
|
||||||
commands:
|
commands:
|
||||||
- 'gem install rake'
|
- 'gem install rake'
|
||||||
- 'bundle config set --local path "vendor/bundle"'
|
- 'bundle config set --local path "vendor/bundle"'
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
$ ->
|
$ ->
|
||||||
# run foundation scripts
|
# run foundation scripts
|
||||||
$(document).foundation()
|
console.log('Ready.')
|
||||||
|
@ -1,55 +1,116 @@
|
|||||||
$(document).ready ->
|
$ ->
|
||||||
$('#generate_button').on 'click', (e) ->
|
chartInstance = null
|
||||||
e.preventDefault()
|
|
||||||
$.ajax(
|
|
||||||
method: 'POST'
|
|
||||||
url: '/reports'
|
|
||||||
data:
|
|
||||||
type: $('#report_type').val()
|
|
||||||
choice: $('#report_choice').val()
|
|
||||||
compare: $('#report_compare').val()
|
|
||||||
).done (data) ->
|
|
||||||
benchChart.options.title.text = data.choice
|
|
||||||
benchChart.data.labels = data.names
|
|
||||||
benchChart.data.datasets[0].data = data.avg_results
|
|
||||||
benchChart.data.datasets[1].data = data.min_results
|
|
||||||
benchChart.update()
|
|
||||||
return
|
|
||||||
return
|
|
||||||
return
|
|
||||||
|
|
||||||
benchChart = new Chart(document.getElementById('chart_canvas').getContext('2d'),
|
$('#report-benchmarks').on 'change', (e) ->
|
||||||
type: 'horizontalBar'
|
$('#report-tests option').prop('selected', false)
|
||||||
data:
|
|
||||||
labels: []
|
$('#reports-download').on 'click', (e) ->
|
||||||
datasets: [
|
e.preventDefault()
|
||||||
{
|
canvas = $('#benchmark-chart')[0]
|
||||||
label: 'Average FPS'
|
a = document.createElement 'a'
|
||||||
data: []
|
a.href = canvas.toDataURL 'image/png'
|
||||||
backgroundColor: 'hotpink'
|
a.download = 'chart.png'
|
||||||
borderColor: '#212121'
|
a.click()
|
||||||
borderWidth: 1
|
|
||||||
}
|
$('#reports-button').on 'click', (e) ->
|
||||||
{
|
e.preventDefault()
|
||||||
label: 'Minimum FPS'
|
$('#reports-download').attr('disabled', true)
|
||||||
data: []
|
chartInstance.destroy() if chartInstance
|
||||||
backgroundColor: 'cornflowerblue'
|
|
||||||
borderColor: '#212121'
|
benchmarkId = $('#report-benchmarks').val()
|
||||||
borderWidth: 1
|
testIds = $('#report-tests').val()
|
||||||
}
|
|
||||||
]
|
benchmarkSearchParams = new URLSearchParams
|
||||||
options:
|
benchmark_id: benchmarkId
|
||||||
title:
|
benchmarkRes = await fetch("/api/v1/benchmark/details?#{benchmarkSearchParams}")
|
||||||
display: true
|
benchmarkData = await benchmarkRes.json()
|
||||||
text: 'N/a'
|
|
||||||
scales: xAxes: [ {
|
data =
|
||||||
display: true
|
labels: []
|
||||||
ticks: beginAtZero: true
|
datasets: []
|
||||||
} ]
|
|
||||||
animation: onComplete: ->
|
switch benchmarkData.scoring
|
||||||
dwnbtn = $('#download_button')
|
when 'pts'
|
||||||
dwnbtn.attr 'href', benchChart.toBase64Image()
|
data.datasets.push({
|
||||||
dwnbtn.attr 'download', 'benchmark_chart.png'
|
label: 'Average Score'
|
||||||
dwnbtn.attr 'disabled', false
|
data: []
|
||||||
return
|
})
|
||||||
)
|
when 'fps'
|
||||||
|
data.datasets.push({
|
||||||
|
label: 'Average FPS'
|
||||||
|
data: []
|
||||||
|
})
|
||||||
|
data.datasets.push({
|
||||||
|
label: 'Minimum FPS'
|
||||||
|
data: []
|
||||||
|
})
|
||||||
|
when 'ms'
|
||||||
|
data.datasets.push({
|
||||||
|
label: 'Average Frame Time'
|
||||||
|
data: []
|
||||||
|
})
|
||||||
|
data.datasets.push({
|
||||||
|
label: 'Minimum Frame Time'
|
||||||
|
data: []
|
||||||
|
})
|
||||||
|
|
||||||
|
for testId in testIds
|
||||||
|
try
|
||||||
|
testSearchParams = new URLSearchParams
|
||||||
|
test_id: testId
|
||||||
|
testRes = await fetch("/api/v1/test/details?#{testSearchParams}")
|
||||||
|
testData = await testRes.json()
|
||||||
|
|
||||||
|
resultSearchParams = new URLSearchParams
|
||||||
|
test_id: testId
|
||||||
|
benchmark_id: benchmarkId
|
||||||
|
resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}")
|
||||||
|
resultData = await resultRes.json()
|
||||||
|
|
||||||
|
avg_total = 0
|
||||||
|
min_total = 0
|
||||||
|
max_total = 0
|
||||||
|
|
||||||
|
for result in resultData
|
||||||
|
avg_total += result.avg_score
|
||||||
|
min_total += result.min_score if result.min_score
|
||||||
|
max_total += result.max_score if result.max_score
|
||||||
|
|
||||||
|
data.labels.push(testData.name)
|
||||||
|
data.datasets[0].data.push(avg_total / resultData.length)
|
||||||
|
console.log(data.datasets[0].data)
|
||||||
|
switch benchmarkData.scoring
|
||||||
|
when 'fps', 'ms'
|
||||||
|
data.datasets[1].data.push(min_total / resultData.length)
|
||||||
|
catch error
|
||||||
|
console.error 'An error occurred while fetching benchmark results.', error
|
||||||
|
|
||||||
|
ctx = $('#benchmark-chart')[0].getContext('2d')
|
||||||
|
|
||||||
|
options =
|
||||||
|
indexAxis: 'y'
|
||||||
|
plugins:
|
||||||
|
title:
|
||||||
|
display: true
|
||||||
|
text: benchmarkData.name
|
||||||
|
font:
|
||||||
|
size: '24'
|
||||||
|
datalabels:
|
||||||
|
anchor: 'end'
|
||||||
|
align: 'left'
|
||||||
|
color: 'black'
|
||||||
|
font:
|
||||||
|
weight: 'bold'
|
||||||
|
formatter: (value) -> value
|
||||||
|
scales:
|
||||||
|
y:
|
||||||
|
beginAtZero: true
|
||||||
|
|
||||||
|
chartInstance = new Chart ctx,
|
||||||
|
type: 'bar'
|
||||||
|
data: data
|
||||||
|
options: options
|
||||||
|
plugins: [ChartDataLabels]
|
||||||
|
|
||||||
|
$('#reports-download').attr('disabled', false)
|
||||||
|
$('#benchmark-chart').removeClass('disabled')
|
||||||
|
@ -10,7 +10,7 @@ fetchTestBenchmarkResults = (testId, benchmarkId) ->
|
|||||||
resultSearchParams = new URLSearchParams
|
resultSearchParams = new URLSearchParams
|
||||||
test_id: testId
|
test_id: testId
|
||||||
benchmark_id: benchmarkId
|
benchmark_id: benchmarkId
|
||||||
resultRes = await fetch("/api/v1/results?#{resultSearchParams}")
|
resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}")
|
||||||
resultData = await resultRes.json()
|
resultData = await resultRes.json()
|
||||||
|
|
||||||
avg_total = 0
|
avg_total = 0
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
$primary-color: cornflowerblue
|
$primary-color: cornflowerblue
|
||||||
$primary-color-highlight: color.adjust($primary-color, $lightness: -10%)
|
$primary-color-highlight: color.adjust($primary-color, $lightness: -10%)
|
||||||
|
|
||||||
|
html
|
||||||
|
width: 100%
|
||||||
|
height: 100%
|
||||||
|
|
||||||
body
|
body
|
||||||
background: rgb(240, 235, 248)
|
background: rgb(240, 235, 248)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
app_dir = File.expand_path("..", __dir__)
|
app_dir = File.expand_path('..', __dir__)
|
||||||
directory app_dir
|
directory app_dir
|
||||||
|
|
||||||
environment 'production'
|
environment ENV.fetch('RACK_ENV', 'development')
|
||||||
|
|
||||||
bind 'tcp://0.0.0.0:9292'
|
bind 'tcp://0.0.0.0:9292'
|
||||||
workers 2
|
workers 2
|
||||||
|
7
src/appinfo.rb
Normal file
7
src/appinfo.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module AppInfo
|
||||||
|
|
||||||
|
VERSION = '0.1.1'
|
||||||
|
|
||||||
|
end
|
@ -3,12 +3,12 @@
|
|||||||
# Helpers - view helper functions
|
# Helpers - view helper functions
|
||||||
module Helpers
|
module Helpers
|
||||||
|
|
||||||
def ruby_version()
|
def ruby_version
|
||||||
return RUBY_VERSION
|
return RUBY_VERSION
|
||||||
end
|
end
|
||||||
|
|
||||||
def app_version()
|
def app_version
|
||||||
`git describe --tags`.strip
|
return AppInfo::VERSION
|
||||||
end
|
end
|
||||||
|
|
||||||
def date_format(date)
|
def date_format(date)
|
||||||
|
@ -7,4 +7,8 @@ class Test < Sequel::Model
|
|||||||
many_to_one :hardware
|
many_to_one :hardware
|
||||||
many_to_many :benchmarks
|
many_to_many :benchmarks
|
||||||
|
|
||||||
|
def has_benchmark(benchmark_id)
|
||||||
|
return benchmarks_dataset.where(Sequel[:benchmarks][:id] => benchmark_id).any?
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ class GameData < Sinatra::Base
|
|||||||
json benchmark.values()
|
json benchmark.values()
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/v1/results' do
|
get '/api/v1/result/list' do
|
||||||
test_id = params[:test_id]
|
test_id = params[:test_id]
|
||||||
benchmark_id = params[:benchmark_id]
|
benchmark_id = params[:benchmark_id]
|
||||||
|
|
||||||
@ -20,4 +20,12 @@ class GameData < Sinatra::Base
|
|||||||
json results.map(&:values)
|
json results.map(&:values)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get '/api/v1/test/details' do
|
||||||
|
test_id = params[:test_id]
|
||||||
|
|
||||||
|
tst = Test.where(id: test_id).first()
|
||||||
|
|
||||||
|
json tst.values()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -65,9 +65,25 @@ class GameData < Sinatra::Base
|
|||||||
|
|
||||||
tst.update(
|
tst.update(
|
||||||
name: params[:test_name],
|
name: params[:test_name],
|
||||||
type: params[:test_type]
|
hardware_id: params[:test_hardware],
|
||||||
|
description: params[:test_description]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# create an array of the selected benchmarks
|
||||||
|
selected_benchmarks = Array(params[:test_benchmarks])
|
||||||
|
# remove benchmarks no longer associated with the test
|
||||||
|
tst.benchmarks.each do |b|
|
||||||
|
if not selected_benchmarks.include?(b)
|
||||||
|
tst.remove_benchmark(b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# associate the benchmarks to the test
|
||||||
|
selected_benchmarks.each do |b|
|
||||||
|
if not tst.has_benchmark(b)
|
||||||
|
tst.add_benchmark(b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
redirect "/test/#{tst.id}"
|
redirect "/test/#{tst.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ require 'sinatra/json'
|
|||||||
require 'sequel'
|
require 'sequel'
|
||||||
require 'sqlite3'
|
require 'sqlite3'
|
||||||
|
|
||||||
|
require_relative 'appinfo'
|
||||||
|
|
||||||
# Load the Sequel timestamps plugin
|
# Load the Sequel timestamps plugin
|
||||||
Sequel::Model.plugin(:timestamps)
|
Sequel::Model.plugin(:timestamps)
|
||||||
# Initialize Sequel gem for database actions
|
# Initialize Sequel gem for database actions
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<label for="benchmark_description">Benchmark description</label>
|
<label for="benchmark_description">Benchmark description</label>
|
||||||
<textarea id="benchmark_description" class="form-control" name="benchmark_description">Enter a description/notes here.</textarea>
|
<textarea id="benchmark_description" class="form-control" name="benchmark_description" placeholder="Enter a description/notes here."></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<label for="benchmark_description">Benchmark description</label>
|
<label for="benchmark_description">Benchmark description</label>
|
||||||
<textarea id="benchmark_description" class="form-control" name="benchmark_description"><%= benchmark.description %></textarea>
|
<textarea id="benchmark_description" class="form-control" name="benchmark_description" placeholder="Enter a description/notes here."><%= benchmark.description %></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -10,16 +10,17 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" charset="utf-8"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/js/bootstrap.min.js" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/js/bootstrap.min.js" charset="utf-8"></script>
|
||||||
<script src="/js/edgeville.js" charset="utf-8"></script>
|
<script src="/js/edgeville.js" charset="utf-8"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js" charset="utf-8"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="d-flex flex-column min-vh-100">
|
||||||
<!-- main navigation -->
|
<!-- main navigation -->
|
||||||
<%= erb :'partials/navbar', :locals => locals %>
|
<%= erb :'partials/navbar', :locals => locals %>
|
||||||
|
|
||||||
<!-- main content -->
|
<!-- main content -->
|
||||||
<div id="wrapper" class="container mb-4">
|
<main class="flex-grow-1 py-4">
|
||||||
<%= yield %>
|
<div id="wrapper" class="container mb-4">
|
||||||
</div>
|
<%= yield %>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
<!-- site footer -->
|
<!-- site footer -->
|
||||||
<%= erb :'partials/footer', :locals => locals %>
|
<%= erb :'partials/footer', :locals => locals %>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
<nav id="main-footer" class="container">
|
<footer id="main-footer" class="bg-light border-top py-3 text-center">
|
||||||
<div class="row">
|
<div class="container">
|
||||||
<div class="col-12">
|
<div class="row">
|
||||||
<p>Game Data version v<%= app_version() %></p>
|
<div class="col-12">
|
||||||
<p>Running Ruby version v<%= ruby_version() %></p>
|
<p>Game Data version v<%= app_version() %></p>
|
||||||
|
<p class="mb-0">Running Ruby version v<%= ruby_version() %></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</footer>
|
@ -2,14 +2,14 @@
|
|||||||
<form class="col-12" action="/reports" method="post">
|
<form class="col-12" action="/reports" method="post">
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-12 col-md-6">
|
<div class="col-12 col-md-6">
|
||||||
<select id="report_type" class="form-select" name="report_type" disabled>
|
<select id="report-type" class="form-select" name="report_type" disabled>
|
||||||
<option value="benchmark">Benchmark</option>
|
<option value="benchmark">Benchmark</option>
|
||||||
<option value="test">Test</option>
|
<option value="test">Test</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-6">
|
<div class="col-12 col-md-6">
|
||||||
<select id="report_choice" class="form-select" name="report_choice">
|
<select id="report-benchmarks" class="form-select" name="report_choice">
|
||||||
<% benchmarks.each do |b| %>
|
<% benchmarks.each do |b| %>
|
||||||
<option value="<%= b.id %>"><%= b.name %></option>
|
<option value="<%= b.id %>"><%= b.name %></option>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 mb-3">
|
<div class="col-12 mb-3">
|
||||||
<select id="report_compare" class="col-12 form-select" name="report_compare[]" multiple>
|
<select id="report-tests" class="col-12 form-select" name="report_compare[]" multiple>
|
||||||
<% tests.each do |t| %>
|
<% tests.each do |t| %>
|
||||||
<option value="<%= t.id %>"><%= t.name %></option>
|
<option value="<%= t.id %>"><%= t.name %></option>
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -26,16 +26,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 mb-3">
|
<div class="col-12 mb-3">
|
||||||
<input type="submit" class="btn btn-primary" id="generate_button" value="Generate">
|
<button id="reports-button" class="btn btn-primary">Generate</button>
|
||||||
<a href="#" class="btn btn-primary" id="download_button" disabled>Download</a>
|
<button id="reports-download" class="btn btn-primary" disabled>Download</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<canvas id="chart_canvas" width="100%" height="25"></canvas>
|
<canvas id="benchmark-chart" width="100%" height="25"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- load the chart.js library -->
|
<!-- load the chart.js library -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js" charset="utf-8"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" charset="utf-8"></script>
|
||||||
<!-- load chart functionality -->
|
<!-- load chart functionality -->
|
||||||
<script src="/js/reports.js" charset="utf-8"></script>
|
<script src="/js/reports.js" charset="utf-8"></script>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<label for="test_benchmarks">Benchmarks</label>
|
<label for="test_benchmarks">Benchmarks</label>
|
||||||
<select id="test_benchmarks" class="form-select" name="test_benchmarks[]" multiple>
|
<select id="test_benchmarks" class="form-select" name="test_benchmarks[]" multiple>
|
||||||
<% for b in benchmarks %>
|
<% for b in benchmarks %>
|
||||||
<option value="<%= b.id %>"><%= b.name %></option>
|
<option value="<%= b.id %>" <% if test.has_benchmark(b.id) %>selected<% end %>><%= b.name %></option>
|
||||||
<% end %>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<input class="btn btn-primary w-100" type="submit" value="Create Test">
|
<input class="btn btn-primary w-100" type="submit" value="Submit Changes">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<p>Hardware tested: <%= test.hardware.name %></p>
|
<p>Hardware tested: <a href="/hardware/<%= test.hardware.id %>"><%= test.hardware.name %></a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
Reference in New Issue
Block a user