public static void StartAppendAggreate(string description) { if (Enabled == false || TimeProvider == null) { return; } if (aggregateEntries.ContainsKey(description) == false) { return; } AggregateEntry entry = aggregateEntries[description]; entry.StartTime = TimeProvider.GetTimestamp(); }
public static void PopAggregate(string description) { if (Enabled == false || TimeProvider == null) { return; } if (aggregateEntries.ContainsKey(description) == false) { return; } AggregateEntry entry = aggregateEntries[description]; aggregateEntries.Remove(description); LogAggregate(entry); }
public static void EndAppendAggreate(string description) { if (Enabled == false || TimeProvider == null) { return; } if (aggregateEntries.ContainsKey(description) == false) { return; } AggregateEntry entry = aggregateEntries[description]; long diff = TimeProvider.GetTimestamp() - entry.StartTime; double seconds = (double)diff / (double)TimeProvider.GetFrequency(); entry.Count++; entry.TotalTimeInSeconds += seconds; }
public static void PushAggregate(string description) { if (Enabled == false || TimeProvider == null) { return; } if (aggregateEntries.ContainsKey(description) == true) { return; } AggregateEntry entry = new AggregateEntry(); entry.Count = 0; entry.StartTime = 0; entry.Description = description; entry.TotalTimeInSeconds = 0; aggregateEntries.Add(description, entry); }
private static void LogAggregate(AggregateEntry entry) { bool performLog = true; if (LogLongRunningTasksOnly == true) { performLog = (entry.TotalTimeInSeconds >= LongRunningTaskThresholdInSeconds); } if (performLog) { double msecs = (entry.TotalTimeInSeconds * 1000); double msecsAvgPerEntry = 0; if (entry.Count > 0) { msecsAvgPerEntry = msecs / (float)entry.Count; } Log.Write(LogType.Performance, LogSeverity.Debug, entry.Description + " took a total " + msecs + " ms with " + msecsAvgPerEntry + " ms on average per entry with a total of " + entry.Count + " entries."); } }