@@ -127,8 +127,6 @@ public class ImportHighScoresCommand
127127
128128 public async Task < int > OnExecuteAsync ( CancellationToken cancellationToken )
129129 {
130- startupTimestamp = DateTimeOffset . Now . ToUnixTimeMilliseconds ( ) ;
131-
132130 if ( ! CheckSlaveLatency )
133131 scoresPerQuery = maximum_scores_per_query ;
134132
@@ -238,19 +236,34 @@ public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)
238236
239237 while ( ! runningBatches . All ( t => t . Task . IsCompleted ) )
240238 {
241- long currentTimestamp = DateTimeOffset . Now . ToUnixTimeSeconds ( ) ;
239+ long currentTimestamp = DateTimeOffset . Now . ToUnixTimeMilliseconds ( ) ;
242240
243- if ( currentTimestamp - lastCommitTimestamp >= seconds_between_report )
241+ if ( ( currentTimestamp - lastCommitTimestamp ) / 1000 >= seconds_between_report )
244242 {
245243 int inserted = Interlocked . Exchange ( ref currentReportInsertCount , 0 ) ;
246244 int updated = Interlocked . Exchange ( ref currentReportUpdateCount , 0 ) ;
247245
248- double secondsPassed = ( double ) ( currentTimestamp - lastCommitTimestamp ) / 1000 ;
246+ // Only set startup timestamp after first insert actual insert/update run to avoid weighting during catch-up.
247+ if ( inserted + updated > 0 && startupTimestamp == 0 )
248+ startupTimestamp = lastCommitTimestamp ;
249+
249250 double secondsSinceStart = ( double ) ( currentTimestamp - startupTimestamp ) / 1000 ;
251+ double processingRate = ( totalInsertCount + totalUpdateCount ) / secondsSinceStart ;
252+
253+ string eta = string . Empty ;
254+
255+ if ( singleRun )
256+ {
257+ double secondsLeft = ( maxProcessableId - lastId ) / processingRate ;
258+
259+ int etaHours = ( int ) ( secondsLeft / 3600 ) ;
260+ int etaMins = ( int ) ( secondsLeft - etaHours * 3600 ) / 60 ;
261+ eta = $ "{ etaHours } h{ etaMins } m";
262+ }
250263
251264 Console . WriteLine ( $ "Inserting up to { lastId : N0} "
252265 + $ "[{ runningBatches . Count ( t => t . Task . IsCompleted ) , - 2 } /{ runningBatches . Count } ] "
253- + $ "{ totalInsertCount : N0} inserted { totalUpdateCount : N0} updated { totalSkipCount : N0} skipped (+{ inserted : N0} new +{ updated : N0} upd { ( inserted + updated ) / secondsPassed : N0} /s { ( totalInsertCount + totalUpdateCount ) / secondsSinceStart } ) ") ;
266+ + $ "{ totalInsertCount : N0} inserted { totalUpdateCount : N0} updated { totalSkipCount : N0} skipped (+{ inserted : N0} new +{ updated : N0} upd) { processingRate : N0} /s { eta } ") ;
254267
255268 lastCommitTimestamp = currentTimestamp ;
256269 }
0 commit comments