computeObjectName static method

Future<String> computeObjectName(
  1. String githubRepo,
  2. String? revision,
  3. DateTime commitTime,
  4. String taskName,
)

Compute the GCS file name that's used to store metrics for a given commit (git revision).

Skia perf needs all directory names to be well formatted. The final name of the json file can be arbitrary, and multiple json files can be put in that leaf directory. We are using multiple json files divided by test names to scale up the system to avoid too many writes competing for the same json file.

Implementation

static Future<String> computeObjectName(String githubRepo, String? revision,
    DateTime commitTime, String taskName) async {
  assert(_githubRepoToGcsName[githubRepo] != null);
  final String? topComponent = _githubRepoToGcsName[githubRepo];
  // [commitTime] is not guranteed to be UTC. Ensure it is so all results
  // pushed to GCS are the same timezone.
  final DateTime commitUtcTime = commitTime.toUtc();
  final String month = commitUtcTime.month.toString().padLeft(2, '0');
  final String day = commitUtcTime.day.toString().padLeft(2, '0');
  final String hour = commitUtcTime.hour.toString().padLeft(2, '0');
  final String dateComponents = '${commitUtcTime.year}/$month/$day/$hour';
  return '$topComponent/$dateComponents/$revision/${taskName}_values.json';
}