From fc193568b9a6169df18174ae5fdafb6f63a839b3 Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Wed, 20 Sep 2023 13:12:03 -0700 Subject: [PATCH] Add RunDetails class for encapsulating benchmark run information Added a new Dart class called `RunDetails` to represent specific details related to a benchmark run. The class includes fields for: - The unique run identifier (`runId`) - The command used to initiate the benchmark (`command`) - The time the benchmark was completed (`completionTime`) - The time the benchmark started (`benchmarkStartTime`) - The name of the test being run (`testName`) Serialization and deserialization methods are also provided for JSON compatibility. --- .../lib/models/benchmark/run_details.dart | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 frontend/lib/models/benchmark/run_details.dart diff --git a/frontend/lib/models/benchmark/run_details.dart b/frontend/lib/models/benchmark/run_details.dart new file mode 100644 index 00000000..49686537 --- /dev/null +++ b/frontend/lib/models/benchmark/run_details.dart @@ -0,0 +1,59 @@ +/// `RunDetails` encapsulates specific details about a benchmark run. +/// +/// This class holds attributes such as the unique run identifier, the command used to initiate the run, +/// the time of completion, the time when the benchmark started, and the name of the test. +class RunDetails { + /// The unique identifier for the benchmark run, typically a UUID. + final String runId; + + /// The command used to initiate the benchmark run. + final String command; + + /// The completion time of the benchmark run as a `DateTime` object. + final DateTime completionTime; + + /// The start time of the benchmark run as a `DateTime` object. + final DateTime benchmarkStartTime; + + /// The name of the test associated with this benchmark run. + final String testName; + + /// Constructs a new `RunDetails` instance. + /// + /// [runId]: The unique identifier for the benchmark run. + /// [command]: The command used to initiate the run. + /// [completionTime]: The completion time of the run. + /// [benchmarkStartTime]: The start time of the run. + /// [testName]: The name of the test. + RunDetails({ + required this.runId, + required this.command, + required this.completionTime, + required this.benchmarkStartTime, + required this.testName, + }); + + /// Creates a `RunDetails` instance from a map. + /// + /// [json]: A map containing key-value pairs corresponding to `RunDetails` fields. + /// + /// Returns a new `RunDetails` populated with values from the map. + factory RunDetails.fromJson(Map json) => RunDetails( + runId: json['run_id'], + command: json['command'], + completionTime: DateTime.parse(json['completion_time']), + benchmarkStartTime: DateTime.parse(json['benchmark_start_time']), + testName: json['test_name'], + ); + + /// Converts the `RunDetails` instance to a map. + /// + /// Returns a map containing key-value pairs corresponding to `RunDetails` fields. + Map toJson() => { + 'run_id': runId, + 'command': command, + 'completion_time': completionTime.toIso8601String(), + 'benchmark_start_time': benchmarkStartTime.toIso8601String(), + 'test_name': testName, + }; +}