目录
此处是和时间(Time,DateTime等)有关的函数
使用前,先做最开始的初始化:
private Dictionary<string, DateTime> calcTimeList; //init for calc time calcTimeList = new Dictionary<string, DateTime>();
每次使用之前,使用:
// init for calculate time span public void elapsedTimeSpanInit(string keyName) { calcTimeList.Add(keyName, DateTime.Now); }
然后就可以获得对应的时间消耗了:
// got calculated time span public double getElapsedTimeSpan(string keyName) { double milliSec = 0.0; if (calcTimeList.ContainsKey(keyName)) { DateTime startTime = calcTimeList[keyName]; DateTime endTime = DateTime.Now; milliSec = (endTime - startTime).TotalMilliseconds; } return milliSec; }