Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: add benchmark stats for metervm
  • Loading branch information
RodrigoVillar committed Sep 26, 2025
commit 8fea01db744ee5f08b8cabef9fb77841cd28bc63
58 changes: 58 additions & 0 deletions tests/reexecute/c/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ var (
},
},
}
meterVMMetrics = []topLevelMetric{
{
Name: "avg_block_parse",
Queries: []string{"avalanche_meterchainvm_C_parse_block"},
},
{
Name: "avg_block_verify",
Queries: []string{"avalanche_meterchainvm_C_verify"},
},
{
Name: "avg_block_accept",
Queries: []string{"avalanche_meterchainvm_C_accept"},
},
}
)

func getCounterMetricValue(registry prometheus.Gatherer, query string) (float64, error) {
Expand All @@ -96,6 +110,38 @@ func getCounterMetricValue(registry prometheus.Gatherer, query string) (float64,
return 0, fmt.Errorf("metric %s not found", query)
}

func getAveragerValue(registry prometheus.Gatherer, query string) (float64, error) {
metricFamilies, err := registry.Gather()
if err != nil {
return 0, fmt.Errorf("failed to gather metrics: %w", err)
}

var (
sumName = query + "_sum"
countName = query + "_count"

sum float64
count float64
)

for _, mf := range metricFamilies {
name := mf.GetName()
switch name {
case sumName:
sum = mf.GetMetric()[0].Gauge.GetValue()
case countName:
count = mf.GetMetric()[0].Counter.GetValue()
default:
}
}

if sum == 0 || count == 0 {
return 0, fmt.Errorf("failed to compute averager value for %s", query)
}

return sum / count, nil
}

type topLevelMetric struct {
Name string
Queries []string
Expand Down Expand Up @@ -129,6 +175,18 @@ func getTopLevelMetrics(b *testing.B, registry prometheus.Gatherer, elapsed time
totalMSTrackedPerGGas += metricValMS
b.ReportMetric(metricValMS, fmt.Sprintf("%s_ms/g%s", metric.Name, gasMetric.Name))
}

for _, metric := range meterVMMetrics {
query := metric.Queries[0]
queryVal, err := getAveragerValue(registry, query)
r.NoError(err)

// convert from ns to ms
queryVal /= 1_000_000

b.ReportMetric(queryVal, metric.Name+"_ms/block")
}

totalSTracked := totalMSTrackedPerGGas / 1000
b.ReportMetric(totalSTracked, "s_tracked")
b.ReportMetric(elapsed.Seconds(), "s_total")
Expand Down