reportMetric function

void reportMetric(
  1. String metric,
  2. num? value, {
  3. Map<String, Object>? extra,
})

Emits one machine-readable benchmark sample on stdout.

Format: HINTFUL_BENCH_JSON:<json>. Every sample carries metric and a nullable value (null = could not measure — the collector skips such samples).

Implementation

void reportMetric(String metric, num? value, {Map<String, Object>? extra}) {
  final payload = <String, Object?>{
    'metric': metric,
    'value': value,
    if (extra != null) ...extra,
  };
  // ignore: avoid_print
  print('$envelope${jsonEncode(payload)}');
}