Executing the calculation method of consuming c #

  Stopwatch watch = Stopwatch.StartNew();

// method to be executed

test();

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

// ms turn all day in hours and minutes

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 + "秒";
}

Guess you like

Origin www.cnblogs.com/macT/p/11334076.html
Recommended