C# 是否有一些库可以帮助编写工具,比如测量方法的执行时间
有没有可以帮助完成这些任务的库 您可以使用秒表类C# 是否有一些库可以帮助编写工具,比如测量方法的执行时间,c#,.net,C#,.net,有没有可以帮助完成这些任务的库 您可以使用秒表类 using System; using System.Diagnostics; using System.Threading; class Program { static void Main(string[] args) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); Thread.Sleep(10000); stopWatch.S
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
}
}
-Visual Studio有一个探查器-我认为它只在专业版和更高版本中可用。总的来说,它工作得很好 如果您有更具体或特殊的需求,您可能需要查看PostSharp或其他附加组件