private static void WriteTicksToLog(DebugWatchInfo dwi) { string filename = ConfigurationManager.AppSettings["DebugLogFile"] as string; if (filename != null) { dwi.ToXml(); _xmlDoc.Save(filename); } }
public static void Stop() { DebugWatchInfo dwi = _watchStack.Pop(); _operations = dwi.ParentOperations; if (dwi.Watch != null) { dwi.Watch.Stop(); WriteTicksToLog(dwi); } }
public static long Start(string operation) { if (_xmlDoc == null) { _xmlDoc = new XmlDocument(); _xmlDoc.AppendChild(_xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null)); _operations = _xmlDoc.CreateElement("operations"); _xmlDoc.AppendChild(_operations); } if (_id == 0) { _id = DateTime.Now.ToFileTimeUtc(); } System.Threading.Interlocked.Increment(ref _id); DebugWatchInfo dwi = new DebugWatchInfo(_id, operation, Stopwatch.StartNew(), _operations); _watchStack.Push(dwi); _operations = (XmlElement)dwi.OperationElement.LastChild; return(_id); }