class Program
{
static void Main(string[] args)
{
Console.WriteLine(ActionExtension.Profiler(a, ));
}
static void a()
{ }
}
//public class test : ICorProfilerCallback
//{
//}
public static class ActionExtension
{
public static string Profiler(this Action func, int runcount)
{
Stopwatch watch = Stopwatch.StartNew();//创建一个监听器
for (int i = ; i < runcount; i++)
{
func();//执行某个方法
}
watch.Stop();
float sec = watch.ElapsedMilliseconds / 1000.0f;
float freq = sec / runcount;
return string.Format("总体执行时间为:{0}秒,总体执行次数为:{1},平均执行时间为:{2}秒", sec, runcount, freq);
}
}