resolveServerTiming static method

String resolveServerTiming(
  1. Map<String, APIMetric> metrics
)

Implementation

static String resolveServerTiming(Map<String, APIMetric> metrics) {
  var s = StringBuffer();

  for (var e in metrics.entries) {
    var metric = e.value;

    if (s.isNotEmpty) {
      s.write(', ');
    }

    s.write(e.key);

    var duration = metric.duration;
    if (duration != null) {
      s.write(';dur=');
      var ms = duration.inMicroseconds / 1000;
      s.write(ms);
    }

    var description = metric.description;
    if (description != null &&
        description.isNotEmpty &&
        !description.contains('"')) {
      s.write(';desc="');
      s.write(description);
      s.write('"');
    }

    var n = metric.n;
    if (n != null) {
      s.write(';int=');
      s.write(n);
    }
  }

  return s.toString();
}