BenchmarkWatch.NET
1.0.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.5
This package targets .NET Framework 4.5. The package is compatible with this framework or higher.
dotnet add package BenchmarkWatch.NET --version 1.0.0
NuGet\Install-Package BenchmarkWatch.NET -Version 1.0.0
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="BenchmarkWatch.NET" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BenchmarkWatch.NET --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BenchmarkWatch.NET, 1.0.0"
#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 BenchmarkWatch.NET as a Cake Addin #addin nuget:?package=BenchmarkWatch.NET&version=1.0.0 // Install BenchmarkWatch.NET as a Cake Tool #tool nuget:?package=BenchmarkWatch.NET&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BenchmarkWatch.NET 介绍
BenchmarkWatch.NET 是为 DOTNET 平台快速定位代码运行耗时所设计, 优化代码执行效率, 快速分析代码质量的分析工具.
支持版本:
- net45
- netstandard2.0
- netstandard2.1
- net6.0
- net7.0
快速使用
- 创建
BenchmarkWatch
对象
var watch = new BenchmarkWatch();
- 使用
BenchmarkWatch.Mark()
方法添加检查标记点.
var watch = new BenchmarkWatch();
watch.Mark();
- 使用
BenchmarkWatch.Print()
获取记录字符串信息
var watch = new BenchmarkWatch();
watch.Mark();
var msgs = watch.Print();
使用示例2
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace BenchmarkWatch.Test
{
public class Program
{
public static NET.BenchmarkWatch BenchmarkWatch = new NET.BenchmarkWatch();
public static void Main(params string[] args)
{
BenchmarkWatch.Mark();
var msgs = GetNext();
BenchmarkWatch.Mark();
var msgsor = msgs.GetEnumerator();
BenchmarkWatch.Mark();
while (msgsor.MoveNext())
{
BenchmarkWatch.Mark();
Console.WriteLine(msgsor.Current);
BenchmarkWatch.Mark();
}
BenchmarkWatch.Mark();
var msges = BenchmarkWatch.Print();
foreach (var msg in msges)
{
Console.WriteLine(msg);
}
}
public static IEnumerable<string> GetNext()
{
for (int i = 0; i < 100; i++)
{
Thread.Sleep(100);
yield return string.Format("run {0}", i);
}
}
}
}
使用示例2
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using BenchmarkWatch.NET;
namespace BenchmarkWatch.Test
{
public class Program
{
public static void Main(params string[] args)
{
var test = new Test();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
test.Method1();
test.Method2();
test.Method3();
var lines = test.Put();
foreach (var ln in lines)
{
Console.WriteLine(ln);
}
}
}
public class Test
{
private NET.BenchmarkWatch _watch = new NET.BenchmarkWatch();
public void Method1()
{
Thread.Sleep(520);
_watch.Mark();
}
public void Method2()
{
Thread.Sleep(620);
_watch.Mark();
}
public void Method3()
{
Thread.Sleep(310);
_watch.Mark();
}
public IEnumerable<string> Put()
{
return _watch.Print();
}
}
}
输出
_watch(at /root/works/BenchmarkWatch.NET/test/Program.cs:65) -> Method1(at /root/works/BenchmarkWatch.NET/test/Program.cs:70) during took a total of 525ms, and executed is 1 times, the avg a times is 525ms
Method1(at /root/works/BenchmarkWatch.NET/test/Program.cs:70) -> Method2(at /root/works/BenchmarkWatch.NET/test/Program.cs:77) during took a total of 7443ms, and executed is 12 times, the avg a times is 620ms
Method2(at /root/works/BenchmarkWatch.NET/test/Program.cs:77) -> Method3(at /root/works/BenchmarkWatch.NET/test/Program.cs:83) during took a total of 3720ms, and executed is 12 times, the avg a times is 310ms
Method3(at /root/works/BenchmarkWatch.NET/test/Program.cs:83) -> Method1(at /root/works/BenchmarkWatch.NET/test/Program.cs:70) during took a total of 5720ms, and executed is 11 times, the avg a times is 520ms
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. 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 is compatible. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 250 | 11/10/2022 |