//导入该命名空间
using System.Diagnostice;
Stopwatch watch=new Stopwatch ();
watch.Start();
/*
此处为要计算的运行代码
*/
watch.Stop();
//获取当前实例测量得出的总运行时间(以毫秒为单位)
string time = watch.ElapsedMilliseconds.ToString();
C# 计算代码执行时间
最新推荐文章于 2023-10-24 10:05:05 发布
//导入该命名空间
using System.Diagnostice;
Stopwatch watch=new Stopwatch ();
watch.Start();
/*
此处为要计算的运行代码
*/
watch.Stop();
//获取当前实例测量得出的总运行时间(以毫秒为单位)
string time = watch.ElapsedMilliseconds.ToString();