This commit is contained in:
CortexCore
2024-12-09 22:57:08 +08:00
parent 21b6da3c21
commit c072be88b6
6780 changed files with 698743 additions and 566 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
namespace BITKit
{
public class StopWatcher:IDisposable
{
private readonly Stopwatch _stopwatch = new Stopwatch();
private readonly ILogger _logger;
private readonly string _message;
public StopWatcher(ILogger logger,string message)
{
_logger = logger;
_message = message;
_logger.LogInformation($"开始计时:{message}");
}
public void Dispose()
{
_stopwatch.Stop();
_logger.LogInformation($"已完成:{_message},耗时{_stopwatch.Elapsed}");
}
}
}