mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 22:44:21 +01:00
Add Metrics class with serialization and documentation
Added a new Metrics class to represent key performance metrics of a benchmark test run. - The Metrics class encapsulates various data points like difficulty, success rate, attempted status, success percentage, cost, and runtime. - Included serialization and deserialization methods for converting between Metrics objects and JSON. - Added comprehensive documentation to describe the purpose, properties, and methods of the Metrics class.
This commit is contained in:
67
frontend/lib/models/benchmark/metrics.dart
Normal file
67
frontend/lib/models/benchmark/metrics.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
/// `Metrics` holds key performance metrics related to a benchmark test run.
|
||||
///
|
||||
/// The class encapsulates various data points like difficulty, success rate,
|
||||
/// whether the task was attempted, the percentage of success, and other performance metrics.
|
||||
class Metrics {
|
||||
/// The perceived difficulty level of the test, usually represented as a string.
|
||||
final String difficulty;
|
||||
|
||||
/// A boolean indicating whether the test was successful.
|
||||
final bool success;
|
||||
|
||||
/// A boolean indicating whether the test was attempted.
|
||||
final bool attempted;
|
||||
|
||||
/// The percentage of success in the test, represented as a double.
|
||||
final double successPercentage;
|
||||
|
||||
/// The cost metric, can be any type depending on what is being measured (time, resources, etc.).
|
||||
/// It is dynamic to allow for various types.
|
||||
final dynamic cost;
|
||||
|
||||
/// The total runtime of the test, represented as a string.
|
||||
final String runTime;
|
||||
|
||||
/// Constructs a new `Metrics` instance.
|
||||
///
|
||||
/// [difficulty]: The perceived difficulty level of the test.
|
||||
/// [success]: A boolean indicating the success status of the test.
|
||||
/// [attempted]: A boolean indicating if the test was attempted.
|
||||
/// [successPercentage]: The success rate as a percentage.
|
||||
/// [cost]: The cost metric for the test.
|
||||
/// [runTime]: The total runtime of the test.
|
||||
Metrics({
|
||||
required this.difficulty,
|
||||
required this.success,
|
||||
required this.attempted,
|
||||
required this.successPercentage,
|
||||
required this.cost,
|
||||
required this.runTime,
|
||||
});
|
||||
|
||||
/// Creates a `Metrics` instance from a map.
|
||||
///
|
||||
/// [json]: A map containing key-value pairs corresponding to `Metrics` fields.
|
||||
///
|
||||
/// Returns a new `Metrics` populated with values from the map.
|
||||
factory Metrics.fromJson(Map<String, dynamic> json) => Metrics(
|
||||
difficulty: json['difficulty'],
|
||||
success: json['success'],
|
||||
attempted: json['attempted'],
|
||||
successPercentage: json['success_percentage'].toDouble(),
|
||||
cost: json['cost'],
|
||||
runTime: json['run_time'],
|
||||
);
|
||||
|
||||
/// Converts the `Metrics` instance to a map.
|
||||
///
|
||||
/// Returns a map containing key-value pairs corresponding to `Metrics` fields.
|
||||
Map<String, dynamic> toJson() => {
|
||||
'difficulty': difficulty,
|
||||
'success': success,
|
||||
'attempted': attempted,
|
||||
'success_percentage': successPercentage,
|
||||
'cost': cost,
|
||||
'run_time': runTime,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user