findBenchmarks function

List<String> findBenchmarks(
  1. List<String> paths
)

The benchmark programs in paths: each file as given, and every *_benchmark.dart file under each directory, sorted.

Throws:

Implementation

List<String> findBenchmarks(List<String> paths) {
  final found = <String>[];
  for (final path in paths) {
    if (FileSystemEntity.isFileSync(path)) {
      found.add(path);
    } else if (FileSystemEntity.isDirectorySync(path)) {
      final files = [
        for (final e in Directory(path).listSync(recursive: true))
          if (e is File && e.path.endsWith('_benchmark.dart')) e.path,
      ]..sort();
      found.addAll(files);
    } else {
      throw FileSystemException('No such file or directory', path);
    }
  }
  return found;
}