计算方法执行完的耗时 c#

2021-02-08 23:17

阅读:648

标签:console   stat   方法   lin   stop   star   watch   long   write   

  Stopwatch watch = Stopwatch.StartNew();

//要执行的方法

test();

watch.Stop();
Console.WriteLine(string.Format("耗时:{0}", formatDuring(watch.ElapsedMilliseconds)));
Console.ReadKey();

//毫秒转成天小时分钟

public static String formatDuring(long mss)
{
long days = mss / (1000 * 60 * 60 * 24);
long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60);
long seconds = (mss % (1000 * 60)) / 1000;
return days + "天" + hours + "小时" + minutes + "分钟" + seconds + "秒";
}

计算方法执行完的耗时 c#

标签:console   stat   方法   lin   stop   star   watch   long   write   

原文地址:https://www.cnblogs.com/macT/p/11334076.html


评论


亲,登录后才可以留言!