Skip to content

Commit

Permalink
perf: use Stopwatch.GetTimestamp and Task.WhenAll
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Mar 2, 2025
1 parent f359fbd commit 46e29ef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Src/CSharpier.Cli/CommandLineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CancellationToken cancellationToken
{
try
{
var stopwatch = Stopwatch.StartNew();
var timestamp = Stopwatch.GetTimestamp();
var commandLineFormatterResult = new CommandLineFormatterResult();

if (commandLineOptions.StandardInFileContents != null)
Expand Down Expand Up @@ -98,7 +98,9 @@ await PerformFormattingSteps(
}
}

commandLineFormatterResult.ElapsedMilliseconds = stopwatch.ElapsedMilliseconds;
commandLineFormatterResult.ElapsedMilliseconds = Stopwatch
.GetElapsedTime(timestamp)
.Milliseconds;
if (!commandLineOptions.WriteStdout)
{
logger.LogInformation(
Expand Down Expand Up @@ -271,7 +273,7 @@ await FormatPhysicalFile(
.ToArray();
try
{
Task.WaitAll(tasks, cancellationToken);
await Task.WhenAll(tasks).WaitAsync(cancellationToken);
}
catch (OperationCanceledException ex)
{
Expand Down

0 comments on commit 46e29ef

Please sign in to comment.