Skip to content

Commit

Permalink
Merge pull request microsoft#1798 from neerajsi-msft/neerajsi/read-in…
Browse files Browse the repository at this point in the history
…dex-tickcount

index-parser: get the time in a cheaper way
  • Loading branch information
derrickstolee authored Feb 13, 2023
2 parents bc1bf29 + 797d7f3 commit 3790eb0
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ private FileSystemTaskResult ParseIndex(
uint entryCount = this.ReadFromIndexHeader();

// Don't want to flood the logs on large indexes so only log every 500ms
const int LoggingTicksThreshold = 5000000;
long nextLogTicks = DateTime.UtcNow.Ticks + LoggingTicksThreshold;
const int LoggingTicksThreshold = 500;
int nextLogTicks = Environment.TickCount + LoggingTicksThreshold;

SortedFolderEntries.InitializePools(tracer, entryCount);
LazyUTF8String.InitializePools(tracer, entryCount);
Expand Down Expand Up @@ -329,10 +329,11 @@ private FileSystemTaskResult ParseIndex(
return result;
}

if (DateTime.UtcNow.Ticks > nextLogTicks)
int curTicks = Environment.TickCount;
if (curTicks - nextLogTicks > 0)
{
tracer.RelatedInfo($"{i}/{entryCount} index entries parsed.");
nextLogTicks = DateTime.UtcNow.Ticks + LoggingTicksThreshold;
nextLogTicks = curTicks + LoggingTicksThreshold;
}
}

Expand Down

0 comments on commit 3790eb0

Please sign in to comment.