Modified the front-end to display averaged results up to two decimals
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2025-08-11 23:39:01 -04:00
parent bc5ae4962f
commit 0a1037e79a
3 changed files with 30 additions and 24 deletions

View File

@ -1,3 +1,21 @@
$ -> $ ->
# run foundation scripts # run foundation scripts
console.log('Ready.') console.log('Ready.')
averageResults = (results, decimals = 2) ->
avgScore = 0
minScore = Infinity
maxScore = -Infinity
factor = (10 ^ decimals)
for result in results
avgScore += result.avg_score
minScore = Math.min(minScore, result.min_score)
maxScore = Math.max(maxScore, result.max_score)
return {
avgScore: Math.round((avgScore / results.length) * factor) / factor,
minScore: minScore,
maxScore: maxScore,
}

View File

@ -67,21 +67,14 @@ $ ->
resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}") resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}")
resultData = await resultRes.json() resultData = await resultRes.json()
avg_total = 0 resultAverage = averageResults(resultData)
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.labels.push(testData.name)
data.datasets[0].data.push(avg_total / resultData.length) data.datasets[0].data.push(resultAverage.avgScore)
console.log(data.datasets[0].data) console.log(data.datasets[0].data)
switch benchmarkData.scoring switch benchmarkData.scoring
when 'fps', 'ms' when 'fps', 'ms'
data.datasets[1].data.push(min_total / resultData.length) data.datasets[1].data.push(resultAverage.minScore)
catch error catch error
console.error 'An error occurred while fetching benchmark results.', error console.error 'An error occurred while fetching benchmark results.', error

View File

@ -13,14 +13,7 @@ fetchTestBenchmarkResults = (testId, benchmarkId) ->
resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}") resultRes = await fetch("/api/v1/result/list?#{resultSearchParams}")
resultData = await resultRes.json() resultData = await resultRes.json()
avg_total = 0 resultAverage = averageResults(resultData)
min_total = 0
max_total = 0
for result in resultData
avg_total += result.avg_score
min_total += result.min_score
max_total += result.max_score
tableRow = $("#results-table tr[data-benchmark-id=#{benchmarkId}]") tableRow = $("#results-table tr[data-benchmark-id=#{benchmarkId}]")
@ -29,14 +22,16 @@ fetchTestBenchmarkResults = (testId, benchmarkId) ->
tableRow.append('<td>' + resultData.length + '</td>') tableRow.append('<td>' + resultData.length + '</td>')
if resultData.length != 0 if resultData.length != 0
tableRow.append('<td>' + (avg_total / resultData.length) + '</td>') tableRow.append('<td>' + resultAverage.avgScore + '</td>')
if benchmarkData.scoring == 'fps'
tableRow.append('<td>' + resultAverage.minScore + '</td>')
tableRow.append('<td>' + resultAverage.maxScore + '</td>')
else
tableRow.append('<td>N/a</td>')
tableRow.append('<td>N/a</td>')
else else
tableRow.append('<td>N/a</td>') tableRow.append('<td>N/a</td>')
if min_total != 0
tableRow.append('<td>' + (min_total / resultData.length) + '</td>')
tableRow.append('<td>' + (max_total / resultData.length) + '</td>')
else
tableRow.append('<td>N/a</td>') tableRow.append('<td>N/a</td>')
tableRow.append('<td>N/a</td>') tableRow.append('<td>N/a</td>')
catch error catch error