Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions scripts/cape-subcommands/submission/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@
padding: 12px 15px;
border-radius: 4px;
}
.winner-item.headline {
border-left-color: #28a745;
background: #eef9f1;
}
.metric-legend {
max-width: 900px;
margin: 20px auto 0;
padding: 12px 18px;
background: rgba(255, 255, 255, 0.9);
border-radius: 8px;
color: #333;
font-size: 0.9em;
text-align: left;
}
.metric-legend p {
margin: 4px 0;
}
.winner-label {
font-size: 0.85em;
color: #6c757d;
Expand Down Expand Up @@ -223,6 +240,12 @@
</div>
</div>

<div class="metric-legend">
<p><strong>💰 Lowest Fee</strong>: what one execution costs on Cardano mainnet. It is the execution fee for CPU and memory plus the reference-script fee for the script size, at the ledger's prices.</p>
<p><strong>📦 Most per Transaction</strong>: how many executions of the most expensive measured case fit in one transaction's budget. No fee raises this limit.</p>
<p>The CPU, memory and size medals show the raw measurements behind both.</p>
</div>

<!-- Fixed Algorithm Scenarios -->
<div class="category-section">
<div class="category-header">
Expand Down Expand Up @@ -253,6 +276,39 @@

{{if gt .submission_count 0}}
<div class="winners">
{{if .winners.total_fee}}
<div class="winner-item headline">
<div class="winner-label"><span class="medal">💰</span> Lowest Fee</div>
<div class="winner-value">{{.winners.total_fee.formatted}} lovelace</div>
{{range $idx, $sub := .winners.total_fee.submissions}}{{if lt $idx 3}}
<div class="winner-submission">{{$sub.compiler}}_{{$sub.version}}_{{$sub.author}}{{if ne $sub.variant "default"}}_{{$sub.variant}}{{end}}</div>
{{end}}{{end}}
{{if gt .winners.total_fee.total 3}}
<div class="winner-more">(+{{sub .winners.total_fee.total 3}} more)</div>
{{end}}
</div>
{{end}}

{{if .winners.scripts_per_tx}}
<div class="winner-item headline">
<div class="winner-label"><span class="medal">📦</span> Most per Transaction</div>
{{if gt .winners.scripts_per_tx.value 0}}
<div class="winner-value">{{.winners.scripts_per_tx.formatted}} scripts</div>
{{range $idx, $sub := .winners.scripts_per_tx.submissions}}{{if lt $idx 3}}
<div class="winner-submission">{{$sub.compiler}}_{{$sub.version}}_{{$sub.author}}{{if ne $sub.variant "default"}}_{{$sub.variant}}{{end}}</div>
{{end}}{{end}}
{{if gt .winners.scripts_per_tx.total 3}}
<div class="winner-more">(+{{sub .winners.scripts_per_tx.total 3}} more)</div>
{{end}}
{{else}}
<div class="winner-value">None fit</div>
<div class="winner-more">The most expensive case exceeds one transaction's budget for every submission.</div>
{{end}}
</div>
{{end}}
</div>
<div class="winners">

{{if .winners.cpu}}
<div class="winner-item">
<div class="winner-label"><span class="medal">🥇</span> Best CPU</div>
Expand Down Expand Up @@ -334,6 +390,39 @@

{{if gt .submission_count 0}}
<div class="winners">
{{if .winners.total_fee}}
<div class="winner-item headline">
<div class="winner-label"><span class="medal">💰</span> Lowest Fee</div>
<div class="winner-value">{{.winners.total_fee.formatted}} lovelace</div>
{{range $idx, $sub := .winners.total_fee.submissions}}{{if lt $idx 3}}
<div class="winner-submission">{{$sub.compiler}}_{{$sub.version}}_{{$sub.author}}{{if ne $sub.variant "default"}}_{{$sub.variant}}{{end}}</div>
{{end}}{{end}}
{{if gt .winners.total_fee.total 3}}
<div class="winner-more">(+{{sub .winners.total_fee.total 3}} more)</div>
{{end}}
</div>
{{end}}

{{if .winners.scripts_per_tx}}
<div class="winner-item headline">
<div class="winner-label"><span class="medal">📦</span> Most per Transaction</div>
{{if gt .winners.scripts_per_tx.value 0}}
<div class="winner-value">{{.winners.scripts_per_tx.formatted}} scripts</div>
{{range $idx, $sub := .winners.scripts_per_tx.submissions}}{{if lt $idx 3}}
<div class="winner-submission">{{$sub.compiler}}_{{$sub.version}}_{{$sub.author}}{{if ne $sub.variant "default"}}_{{$sub.variant}}{{end}}</div>
{{end}}{{end}}
{{if gt .winners.scripts_per_tx.total 3}}
<div class="winner-more">(+{{sub .winners.scripts_per_tx.total 3}} more)</div>
{{end}}
{{else}}
<div class="winner-value">None fit</div>
<div class="winner-more">The most expensive case exceeds one transaction's budget for every submission.</div>
{{end}}
</div>
{{end}}
</div>
<div class="winners">

{{if .winners.cpu}}
<div class="winner-item">
<div class="winner-label"><span class="medal">🥇</span> Best CPU</div>
Expand Down
18 changes: 14 additions & 4 deletions scripts/cape-subcommands/submission/report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -635,16 +635,24 @@ categorize_scenario() {
echo "$category"
}

# Returns JSON with winners for each of the four headline metrics (handles ties).
# Returns JSON with winners for each headline metric (handles ties). Two lead:
# the total fee (execution fee plus reference-script fee), which is what one
# execution costs and weighs CPU, memory and size the way the ledger does; and
# scripts per transaction, the most worst-case executions that fit in one
# transaction's budget, a limit no fee can raise.
find_winners() {
local benchmark_csv="$1"

build_winners_json() {
local metric_col="$1"
local metric_name="$2"
# "min" for costs, "max" for capacity (more scripts per transaction is better).
local best="${3:-min}"
local sort_flags="-n"
[ "$best" = "max" ] && sort_flags="-rn"

local best_value
best_value=$(echo "$benchmark_csv" | awk -F, -v col="$metric_col" '{print $col}' | sort -n | head -1)
best_value=$(echo "$benchmark_csv" | awk -F, -v col="$metric_col" '{print $col}' | sort $sort_flags | head -1)

if [ -z "$best_value" ]; then
echo "null"
Expand Down Expand Up @@ -680,13 +688,15 @@ find_winners() {
echo -n "]}"
}

local cpu_json memory_json script_json term_json
local fee_json per_tx_json cpu_json memory_json script_json term_json
fee_json=$(build_winners_json "${CSV_COL[total_fee_lovelace]}" "total_fee")
per_tx_json=$(build_winners_json "${CSV_COL[scripts_per_tx]}" "scripts_per_tx" max)
cpu_json=$(build_winners_json "${CSV_COL[cpu_units]}" "cpu")
memory_json=$(build_winners_json "${CSV_COL[memory_units]}" "memory")
script_json=$(build_winners_json "${CSV_COL[script_size_bytes]}" "script_size")
term_json=$(build_winners_json "${CSV_COL[term_size]}" "term_size")

echo "{\"cpu\":$cpu_json,\"memory\":$memory_json,\"script_size\":$script_json,\"term_size\":$term_json}"
echo "{\"total_fee\":$fee_json,\"scripts_per_tx\":$per_tx_json,\"cpu\":$cpu_json,\"memory\":$memory_json,\"script_size\":$script_json,\"term_size\":$term_json}"
}

generate_index_report() {
Expand Down
Loading