group function

FutureOr<void> group(
  1. String description,
  2. FutureOr<void> body()
)

Defines a benchmark group.

Note: Groups may not be nested.

Implementation

FutureOr<void> group(
  String description,
  FutureOr<void> Function() body,
) async {
  final isAsync = (body is Future<void> Function());

  if (isAsync) {
    description = hourGlass + description;
  }

  final instance = Group(
    description.style(ColorProfile.group),
    body,
  );
  if (isAsync) {
    return instance.runAsync();
  } else {
    instance.run();
  }
}