Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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.");
            }
        }