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
Next Next commit
Generalize benchmark top level metrics def
  • Loading branch information
aaronbuchwald authored and RodrigoVillar committed Sep 26, 2025
commit 5e4509a5436799e57e20f95ba7ae012c4b493b47
28 changes: 24 additions & 4 deletions tests/reexecute/c/vm_reexecute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ var (
"state-sync-enabled": false
}`,
}
topLevelMetrics = []topLevelMetric{
{
MetricName: "mgas/s",
Queries: []string{"avalanche_evm_eth_chain_block_gas_used_processed"},
Denominator: 1_000_000,
},
}

configNameArg string
runnerNameArg string
Expand Down Expand Up @@ -593,13 +600,26 @@ func parseCustomLabels(labelsStr string) (map[string]string, error) {
return labels, nil
}

type topLevelMetric struct {
MetricName string
Queries []string
Denominator float64
}

func getTopLevelMetrics(b *testing.B, registry prometheus.Gatherer, elapsed time.Duration) {
r := require.New(b)

gasUsed, err := getCounterMetricValue(registry, "avalanche_evm_eth_chain_block_gas_used_processed")
r.NoError(err)
mgasPerSecond := gasUsed / 1_000_000 / elapsed.Seconds()
b.ReportMetric(mgasPerSecond, "mgas/s")
for _, metric := range topLevelMetrics {
metricCounterVal := float64(0)
for _, query := range metric.Queries {
val, err := getCounterMetricValue(registry, query)
r.NoError(err, "failed to get counter value for metric %q from query %q", metric.MetricName, query)
metricCounterVal += val
}

metricPerSecond := metricCounterVal / metric.Denominator / elapsed.Seconds()
b.ReportMetric(metricPerSecond, metric.MetricName)
}
}

func getCounterMetricValue(registry prometheus.Gatherer, query string) (float64, error) {
Expand Down