@@ -272,7 +272,7 @@ pub async fn enqueue_shas(
272272 msg. push ( '\n' ) ;
273273 }
274274
275- let artifacts_in_queue = ctxt . missing_commits ( ) . await . len ( ) ;
275+ let preceding_artifacts = count_preceding_in_queue ( ctxt , & try_commit ) . await ;
276276 let last_duration = conn
277277 . last_artifact_collection ( )
278278 . await
@@ -282,20 +282,17 @@ pub async fn enqueue_shas(
282282 // "Guess" that the duration will take about an hour if we don't have data or it's
283283 // suspiciously fast.
284284 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 ;
285287
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 {
292289 "is"
293290 } else {
294291 "are"
295292 } ;
296- let suffix = if other_artifact_count == 1 { "" } else { "s" } ;
293+ let suffix = if preceding_artifacts == 1 { "" } else { "s" } ;
297294 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).
299296It will probably take at least ~{:.1} hours until the benchmark run finishes."# ,
300297 ( expected_duration / 3600.0 )
301298 ) ;
@@ -317,6 +314,15 @@ It will probably take at least ~{:.1} hours until the benchmark run finishes."#,
317314 Ok ( ( ) )
318315}
319316
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+
320326#[ derive( Debug , Deserialize ) ]
321327#[ serde( tag = "type" ) ]
322328enum HomuComment {
0 commit comments