c# 计算程序执行时间
2010-05-20 13:55
656 查看
C#测试代码效率的方法using System; using System.Threading; class Dachie { [System.Runtime.InteropServices.DllImport("Kernel32.dll")] static extern bool QueryPerformanceCounter(ref long count); [System.Runtime.InteropServices.DllImport("Kernel32.dll")] static extern bool QueryPerformanceFrequency(ref long count); [STAThread] static void Main(string[] args) { long count = 0; long count1 = 0; long freq = 0; double result = 0; QueryPerformanceFrequency(ref freq); QueryPerformanceCounter(ref count); #region 放入逻辑代码 #endregion QueryPerformanceCounter(ref count1); count = count1 - count; result = (double)(count) / (double)freq; Console.WriteLine("耗时: {0} 秒", result); Console.ReadLine(); } }
相关文章推荐
- C# 程序找出文件重复的行,计算函数执行的时间
- 用C#计算程序执行的时间间隔
- C#:程序控制--计算程序执行耗费的时间
- C# TimeSpan类计算程序执行的时间及此类的其他常用方法
- C#计算程序执行的时间间隔
- 用C#计算程序执行的时间间隔
- C#计算程序执行过程花费时间的方法
- c# 计算程序执行时间,计算一段代码执行所用的时间,测试效率
- c#中精确计算程序执行时间
- [转载]C#计算程序执行时间
- c# 计算程序执行时间方法
- C# 定时器事件(设置时间间隔,间歇性执行某一函数,控制台程序)
- Linux 精准计时-暨计算程序或函数执行的时间
- c# 统计方法执行时间,计算缓存读取数据方法的命中率
- 使用QueryPerformanceFrequency 计算程序执行时间
- C#计算程序执行速度
- 编写一个C#程序,要求定义一个行数和列数相等的二维数组, 并执行初始化,然后计算并输出数组两条对角线上的元素之和。
- 【C# 计算代码的执行时间】
- 计算程序运行时间C#
- C# StringBuilder的介绍和使用、Stopwatch 计算程序运行的时间