Benchmark: HTML-raportti laskee pisteet itse (toimii vanhoilla tuloksilla)
This commit is contained in:
@@ -49,9 +49,25 @@
|
|||||||
<table id="results-table"><thead></thead><tbody></tbody></table>
|
<table id="results-table"><thead></thead><tbody></tbody></table>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const DATA = /*DATA_PLACEHOLDER*/[];
|
const RAW = /*DATA_PLACEHOLDER*/[];
|
||||||
|
|
||||||
const starsFor = s => s >= 90 ? '★★★★★' : s >= 70 ? '★★★★☆' : s >= 50 ? '★★★☆☆' : s >= 25 ? '★★☆☆☆' : s > 0 ? '★☆☆☆☆' : '☆☆☆☆☆';
|
const starsFor = s => s >= 90 ? '★★★★★' : s >= 70 ? '★★★★☆' : s >= 50 ? '★★★☆☆' : s >= 25 ? '★★☆☆☆' : s > 0 ? '★☆☆☆☆' : '☆☆☆☆☆';
|
||||||
|
function calcScore(r) {
|
||||||
|
if (r.error && r.testsTotal === 0) return 0;
|
||||||
|
let s = 0;
|
||||||
|
if (r.specOk) s += 10;
|
||||||
|
if (!r.error || r.testsTotal > 0) s += 10;
|
||||||
|
if (r.testsTotal > 0) s += Math.round((r.testsPassed / r.testsTotal) * 60);
|
||||||
|
s += Math.max(0, 20 - (r.fixRounds || 0) * 10);
|
||||||
|
return Math.min(100, s);
|
||||||
|
}
|
||||||
|
// Laske pisteet jos puuttuvat
|
||||||
|
const DATA = RAW.map(r => {
|
||||||
|
if (r.score == null) r.score = calcScore(r);
|
||||||
|
if (!r.stars) r.stars = starsFor(r.score);
|
||||||
|
if (!r.promptTokensEst) r.promptTokensEst = r.promptChars ? Math.round(r.promptChars / 4) : 0;
|
||||||
|
return r;
|
||||||
|
});
|
||||||
const cls = r => (!r.error && r.testsPassed === r.testsTotal && r.testsTotal > 0) ? 'pass' : (r.testsTotal > 0 && r.testsPassed > 0) ? 'partial' : 'fail';
|
const cls = r => (!r.error && r.testsPassed === r.testsTotal && r.testsTotal > 0) ? 'pass' : (r.testsTotal > 0 && r.testsPassed > 0) ? 'partial' : 'fail';
|
||||||
const pctBar = (passed, total, w=80) => {
|
const pctBar = (passed, total, w=80) => {
|
||||||
if (total === 0) return '-';
|
if (total === 0) return '-';
|
||||||
|
|||||||
Reference in New Issue
Block a user