Skip to content

Commit

Permalink
Show overall rate
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Dec 11, 2023
1 parent 98912d4 commit e3a698d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class ImportHighScoresCommand
public bool SkipIndexing { get; set; }

private long lastCommitTimestamp;
private long startupTimestamp;
private long lastLatencyCheckTimestamp;

private ElasticQueueProcessor? elasticQueueProcessor;
Expand Down Expand Up @@ -126,6 +127,8 @@ public class ImportHighScoresCommand

public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)
{
startupTimestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();

if (!CheckSlaveLatency)
scoresPerQuery = maximum_scores_per_query;

Expand Down Expand Up @@ -242,9 +245,12 @@ public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)
int inserted = Interlocked.Exchange(ref currentReportInsertCount, 0);
int updated = Interlocked.Exchange(ref currentReportUpdateCount, 0);

double secondsPassed = (double)(currentTimestamp - lastCommitTimestamp) / 1000;
double secondsSinceStart = (double)(currentTimestamp - startupTimestamp) / 1000;

Console.WriteLine($"Inserting up to {lastId:N0} "
+ $"[{runningBatches.Count(t => t.Task.IsCompleted),-2}/{runningBatches.Count}] "
+ $"{totalInsertCount:N0} inserted {totalUpdateCount:N0} updated {totalSkipCount:N0} skipped (+{inserted:N0} new +{updated:N0} upd {(inserted + updated) / seconds_between_report:N0}/s)");
+ $"{totalInsertCount:N0} inserted {totalUpdateCount:N0} updated {totalSkipCount:N0} skipped (+{inserted:N0} new +{updated:N0} upd {(inserted + updated) / secondsPassed:N0}/s {(totalInsertCount + totalUpdateCount) / secondsSinceStart})");

lastCommitTimestamp = currentTimestamp;
}
Expand Down

0 comments on commit e3a698d

Please sign in to comment.