Improve logging performance by checking Trace/Debug log level is enabled (#12793)

This commit is contained in:
Chad
2023-06-07 21:47:05 +12:00
committed by GitHub
parent 9bafdbd992
commit e784cfa960
69 changed files with 648 additions and 224 deletions

View File

@@ -45,7 +45,7 @@ public class RuntimeHash : IRuntimeHash
/// </remarks>
private string GetFileHash(IEnumerable<(FileSystemInfo fileOrFolder, bool scanFileContent)> filesAndFolders)
{
using (_logger.DebugDuration<RuntimeHash>("Determining hash of code files on disk", "Hash determined"))
using (!_logger.IsEnabled(Logging.LogLevel.Debug) ? null : _logger.DebugDuration<RuntimeHash>("Determining hash of code files on disk", "Hash determined"))
{
// get the distinct file infos to hash
var uniqInfos = new HashSet<string>();