什么是衡量一个函数的执行时间的最好方法? [英] What is the best way to measure execution time of a function?

查看:112
本文介绍了什么是衡量一个函数的执行时间的最好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很显然,我可以做, DateTime.Now.After - DateTime.Now.Before ,但一定有什么东西更复杂的。

Obviously I can do and DateTime.Now.After - DateTime.Now.Before but there must be something more sophisticated.

感谢任何提示。

推荐答案

System.Environment.TickCount 和的 System.Diagnostics.Stopwatch 类两种,对于更高的分辨率和简单的使用工作。

System.Environment.TickCount and the System.Diagnostics.Stopwatch class are two that work well for finer resolution and straightforward usage.

另请参见:

  • Is DateTime.Now the best way to measure a function’s performance?
  • High resolution timer in .NET
  • Environment.TickCount vs DateTime.Now
  • What’s the best way to benchmark programs in Windows?

这篇关于什么是衡量一个函数的执行时间的最好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆