report static method

String report({
  1. String title = 'D4rt init profile',
})

Human-readable multi-line report, longest span first.

Implementation

static String report({String title = 'D4rt init profile'}) {
  if (_entries.isEmpty) return '$title: (no spans recorded)';
  final rows = _entries.values.toList()
    ..sort((a, b) => b.totalMicros.compareTo(a.totalMicros));
  final nameW = rows.map((e) => e.name.length).fold<int>(4, max);
  final buf = StringBuffer()..writeln('$title:');
  for (final e in rows) {
    final ms = (e.totalMicros / 1000.0).toStringAsFixed(3);
    buf.writeln('  ${e.name.padRight(nameW)}  ${ms.padLeft(10)} ms  '
        '(${e.count}x)');
  }
  return buf.toString().trimRight();
}