@@ -1026,6 +1026,10 @@ impl BenchmarkRequest {
1026
1026
. collect :: < Result < Vec < _ > , _ > > ( )
1027
1027
. map_err ( |e| anyhow:: anyhow!( "Invalid backend: {e}" ) )
1028
1028
}
1029
+
1030
+ pub fn is_completed ( & self ) -> bool {
1031
+ matches ! ( self . status, BenchmarkRequestStatus :: Completed { .. } )
1032
+ }
1029
1033
}
1030
1034
1031
1035
/// Cached information about benchmark requests in the DB
@@ -1047,6 +1051,70 @@ impl BenchmarkRequestIndex {
1047
1051
pub fn completed_requests ( & self ) -> & HashSet < String > {
1048
1052
& self . completed
1049
1053
}
1054
+
1055
+ pub fn add_tag ( & mut self , tag : & str ) {
1056
+ self . completed . insert ( tag. to_string ( ) ) ;
1057
+ }
1058
+ }
1059
+
1060
+ #[ derive( Debug , Clone , PartialEq ) ]
1061
+ pub enum BenchmarkJobStatus {
1062
+ Queued ,
1063
+ InProgress ,
1064
+ Success ,
1065
+ Failure ,
1066
+ }
1067
+
1068
+ impl BenchmarkJobStatus {
1069
+ pub fn as_str ( & self ) -> & str {
1070
+ match self {
1071
+ BenchmarkJobStatus :: Queued => "queued" ,
1072
+ BenchmarkJobStatus :: InProgress => "in_progress" ,
1073
+ BenchmarkJobStatus :: Success => "success" ,
1074
+ BenchmarkJobStatus :: Failure => "failure" ,
1075
+ }
1076
+ }
1077
+ }
1078
+
1079
+ impl fmt:: Display for BenchmarkJobStatus {
1080
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1081
+ write ! ( f, "{}" , self . as_str( ) )
1082
+ }
1083
+ }
1084
+
1085
+ #[ derive( Debug , Clone , PartialEq ) ]
1086
+ pub struct BenchmarkJob {
1087
+ pub target : Target ,
1088
+ pub backend : CodegenBackend ,
1089
+ pub benchmark_set : u32 ,
1090
+ pub collector_id : String ,
1091
+ pub created_at : Option < DateTime < Utc > > ,
1092
+ pub started_at : Option < DateTime < Utc > > ,
1093
+ pub completed_at : Option < DateTime < Utc > > ,
1094
+ pub status : BenchmarkJobStatus ,
1095
+ pub retry : u32 ,
1096
+ }
1097
+
1098
+ impl BenchmarkJob {
1099
+ pub fn new (
1100
+ target : Target ,
1101
+ backend : CodegenBackend ,
1102
+ benchmark_set : u32 ,
1103
+ collector_id : & str ,
1104
+ status : BenchmarkJobStatus ,
1105
+ ) -> Self {
1106
+ BenchmarkJob {
1107
+ target,
1108
+ backend,
1109
+ benchmark_set,
1110
+ collector_id : collector_id. to_string ( ) ,
1111
+ created_at : None ,
1112
+ started_at : None ,
1113
+ completed_at : None ,
1114
+ status,
1115
+ retry : 0 ,
1116
+ }
1117
+ }
1050
1118
}
1051
1119
1052
1120
#[ derive( Debug , Clone , PartialEq ) ]
0 commit comments