Example #1
0
        /// <summary>
        /// Creates and starts a new performance log entry.
        /// </summary>
        /// <returns>A performance log entry of type <see cref="PerformanceLogEntry"/>.</returns>
        public static PerformanceLogEntry CreateAndStart()
        {
            var entry = new PerformanceLogEntry();

            entry.Start();

            return(entry);
        }
Example #2
0
        /// <summary>
        /// Logs a performance message.
        /// </summary>
        /// <param name="message">A message to log in addition to the performance portion.</param>
        /// <param name="logEntry">An object representing the performance log entry.</param>
        public void LogPerformance(string message, PerformanceLogEntry logEntry)
        {
            logEntry.Stop();

            if (logEntry == null)
            {
                return;
            }

            var msg = $"{message}: {logEntry.ElapsedTime.TotalSeconds} seconds";

            LogInternal(msg, LogLevel.Performance);
        }