@@ -272,7 +272,7 @@ pub async fn enqueue_shas(
272
272
msg. push ( '\n' ) ;
273
273
}
274
274
275
- let artifacts_in_queue = ctxt . missing_commits ( ) . await . len ( ) ;
275
+ let preceding_artifacts = count_preceding_in_queue ( ctxt , & try_commit ) . await ;
276
276
let last_duration = conn
277
277
. last_artifact_collection ( )
278
278
. await
@@ -282,20 +282,17 @@ pub async fn enqueue_shas(
282
282
// "Guess" that the duration will take about an hour if we don't have data or it's
283
283
// suspiciously fast.
284
284
let last_duration = last_duration. max ( Duration :: from_secs ( 3600 ) ) ;
285
+ // Also add the currently queued artifact to the duration
286
+ let expected_duration = ( last_duration. as_secs ( ) * ( preceding_artifacts + 1 ) ) as f64 ;
285
287
286
- let expected_duration = ( last_duration. as_secs ( ) * artifacts_in_queue as u64 ) as f64 ;
287
-
288
- // At this point, the queue should also contain the commit that we're mentioning below.
289
- let other_artifact_count = artifacts_in_queue. saturating_sub ( 1 ) ;
290
-
291
- let verb = if other_artifact_count == 1 {
288
+ let verb = if preceding_artifacts == 1 {
292
289
"is"
293
290
} else {
294
291
"are"
295
292
} ;
296
- let suffix = if other_artifact_count == 1 { "" } else { "s" } ;
293
+ let suffix = if preceding_artifacts == 1 { "" } else { "s" } ;
297
294
let queue_msg = format ! (
298
- r#"There {verb} currently {other_artifact_count } other artifact{suffix} in the [queue](https://perf.rust-lang.org/status.html).
295
+ r#"There {verb} currently {preceding_artifacts } other artifact{suffix} in the [queue](https://perf.rust-lang.org/status.html).
299
296
It will probably take at least ~{:.1} hours until the benchmark run finishes."# ,
300
297
( expected_duration / 3600.0 )
301
298
) ;
@@ -317,6 +314,15 @@ It will probably take at least ~{:.1} hours until the benchmark run finishes."#,
317
314
Ok ( ( ) )
318
315
}
319
316
317
+ /// Counts how many artifacts are in the queue before the specified commit.
318
+ async fn count_preceding_in_queue ( ctxt : & SiteCtxt , commit : & TryCommit ) -> u64 {
319
+ let queue = ctxt. missing_commits ( ) . await ;
320
+ queue
321
+ . iter ( )
322
+ . position ( |( c, _) | c. sha == commit. sha ( ) )
323
+ . unwrap_or ( queue. len ( ) ) as u64
324
+ }
325
+
320
326
#[ derive( Debug , Deserialize ) ]
321
327
#[ serde( tag = "type" ) ]
322
328
enum HomuComment {
0 commit comments