Stopwatch.CommunityToolKit
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Stopwatch.CommunityToolKit --version 1.0.1
NuGet\Install-Package Stopwatch.CommunityToolKit -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Stopwatch.CommunityToolKit" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Stopwatch.CommunityToolKit --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Stopwatch.CommunityToolKit, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Stopwatch.CommunityToolKit as a Cake Addin #addin nuget:?package=Stopwatch.CommunityToolKit&version=1.0.1 // Install Stopwatch.CommunityToolKit as a Cake Tool #tool nuget:?package=Stopwatch.CommunityToolKit&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Stopwatch.CommunityToolKit社区工具包
记录执行方法耗时工具包
- 帮助您在编写快速日志记录方法执行时间 需自行实现日志方法记录程序耗时
Definition
Namespace: Stopwatch.CommunityToolKit Assembly: Stopwatch.CommunityToolKit.dll
Examples
// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.Logging;
using MultiThread.CommunityToolKit;
using Stopwatch.CommunityToolKit;
Console.WriteLine("Hello, World!");
var logger = new MyLogger();
logger.LogInformation("haha");
var list = new List<int>();
for (int i = 0; i < 100; i++)
{
list.Add(i);
}
StopwatchJobHelper.Do(() =>
{
list.ForEach(
r =>
{
Console.WriteLine(r);
Thread.Sleep(100);//模拟每个人物耗时100ms
}
);
}, logger, "单线程");
Console.ReadLine();
//自行实现日志
class MyLogger : ILogger
{
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (logLevel==LogLevel.Information)
{
Console.WriteLine(state);
}
}
public bool IsEnabled(LogLevel logLevel)
{
throw new NotImplementedException();
}
public IDisposable BeginScope<TState>(TState state)
{
throw new NotImplementedException();
}
}
测试效果
可以看到对执行程序做了执行时间记录
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.