Modified the front-end to display averaged results up to two decimals
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -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,
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user