如下参考实例:
TimeSpan ts= new TimeSpan(0);
TimeSpan ts2 = new TimeSpan(0);
foreach (var item in alarmListOfSpecifyOrg)
{
if (_graphicsManager.ExistsAlarm(_graphicsManager.AlarmGraphics, item))
continue;
//long aa = System.Environment.TickCount;
DateTime a1 = DateTime.Now;
Graphic g = _graphicsManager.AlarmDataToGraphic(item);
DateTime a2 = DateTime.Now;
ts = ts+(a2 - a1);
// long bb = System.Environment.TickCount - aa;
// s += bb;
if (g != null)
{
// long cc = System.Environment.TickCount;
DateTime b1 = DateTime.Now;
_graphicsManager.Graphics.Add(g);
DateTime b2 = DateTime.Now;
ts2 = ts2 + (b2 - b1);
}
}
System.Diagnostics.Debug.WriteLine("创建:" + ts.TotalMilliseconds);
System.Diagnostics.Debug.WriteLine("添加:" + ts2.TotalMilliseconds);
_graphicsLayerHelper.GLayer.Visible = true;
//long gg = System.Environment.TickCount - qq;
//DateTime b = DateTime.Now;
// TimeSpan ts = b - a;
//System.Diagnostics.Debug.WriteLine("总计:" +ts.TotalMilliseconds);
}