Added code to update test results

This commit is contained in:
Gregory Ballantine 2024-06-03 14:18:34 -04:00
parent 5a79baca7d
commit 3309d3e2ca
3 changed files with 31 additions and 17 deletions

View File

@ -32,5 +32,17 @@ addResult = (e) ->
result_min: $('#result_min').val() result_min: $('#result_min').val()
result_max: $('#result_max').val() result_max: $('#result_max').val()
}, (data) -> }, (data) ->
console.log(data) dataRow = $('tr[data-benchmark=' + $('#result_benchmark').val() + ']')
numResultsElem = dataRow.children('[data-result-count]').eq(0)
numResults = numResultsElem.text()
avgElem = dataRow.children('[data-result-avg]').eq(0)
avgElem.text(((avgElem.text() * numResults) + $('#result_avg').val()) / (numResults + 1))
minElem = dataRow.children('[data-result-min]').eq(0)
minElem.text(((minElem.text() * numResults) + $('#result_min').val()) / (numResults + 1))
maxElem = dataRow.children('[data-result-max]').eq(0)
maxElem.text(((maxElem.text() * numResults) + $('#result_max').val()) / (numResults + 1))
numResultsElem.text(numResults + 1)
) )

View File

@ -41,21 +41,23 @@ class Test extends Model {
} }
$data[$i] = [ $data[$i] = [
'name' => $b->name, 'benchmark_id' => $b->id,
'scoring' => $b->scoring, 'name' => $b->name,
'count' => count($benchmarkResults), 'scoring' => $b->scoring,
'average' => (array_sum($averageResults) / count($averageResults)), 'count' => count($benchmarkResults),
'minimum' => (array_sum($minimumResults) / count($minimumResults)), 'average' => (array_sum($averageResults) / count($averageResults)),
'maximum' => (array_sum($maximumResults) / count($maximumResults)), 'minimum' => (array_sum($minimumResults) / count($minimumResults)),
'maximum' => (array_sum($maximumResults) / count($maximumResults)),
]; ];
} else { } else {
$data[$i] = [ $data[$i] = [
'name' => $b->name, 'benchmark_id' => $b->id,
'scoring' => $b->scoring, 'name' => $b->name,
'count' => count($benchmarkResults), 'scoring' => $b->scoring,
'average' => 0, 'count' => count($benchmarkResults),
'minimum' => 0, 'average' => 0,
'maximum' => 0, 'minimum' => 0,
'maximum' => 0,
]; ];
} }
} }

View File

@ -64,13 +64,13 @@
</thead> </thead>
<tbody> <tbody>
{% for r in test.benchmarkResults() %} {% for r in test.benchmarkResults() %}
<tr> <tr data-benchmark="{{ r.benchmark_id }}">
<td>{{ r.name }}</td> <td>{{ r.name }}</td>
<td>{{ r.scoring | capitalize }}</td> <td>{{ r.scoring | capitalize }}</td>
<td>{{ r.count }}</td> <td>{{ r.count }}</td>
<td>{{ r.average }}</td> <td data-result-avg>{{ r.average }}</td>
<td>{{ r.minimum ? r.minimum : 'N/a' }}</td> <td data-result-min>{{ r.minimum ? r.minimum : 'N/a' }}</td>
<td>{{ r.maximum ? r.maximum : 'N/a' }}</td> <td data-result-max>{{ r.maximum ? r.maximum : 'N/a' }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>