writeBenchmarkResultJson function

Future<void> writeBenchmarkResultJson(
  1. String path,
  2. BenchmarkResult result
)

Writes result as pretty JSON to an absolute VM file path.

Creates parent directories as needed and throws ArgumentError for relative paths.

Implementation

Future<void> writeBenchmarkResultJson(
  String path,
  BenchmarkResult result,
) async {
  final file = _absoluteFile(path);
  await file.parent.create(recursive: true);
  await file.writeAsString(
    const JsonEncoder.withIndent(' ').convert(result.toJson()),
    flush: true,
  );
}