Пример #1
0
        public static CustomTiming CustomTimingIf(string category, string commandString, decimal minSaveMs, string executeType = null)
        {
            var result = new CustomTiming(Current, commandString, minSaveMs)
            {
                ExecuteType = executeType,
                Category    = category
            };

            // THREADING: revisit
            Current.Head.AddCustomTiming(category, result);

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Initialises a new instance of the <see cref="SqlTiming"/> class.
        /// Creates a new <c>SqlTiming</c> to profile 'command'.
        /// </summary>
        public SqlTiming(ProfiledDbCommand command, SqlExecuteType type, MiniProfiler profiler)
        {
            if (profiler == null)
            {
                throw new ArgumentNullException("profiler");
            }
            _profiler = profiler;

            var commandText = AddSpacesToParameters(command.CommandText);
            var parameters  = GetCommandParameters(command);

            Command       = command;
            commandText   = Settings.SqlFormatter.FormatSql(commandText, parameters);
            _customTiming = MiniProfiler.CustomTiming("sql", commandText, type.ToString());
            if (_customTiming == null)
            {
                throw new InvalidOperationException();
            }
        }
Пример #3
0
 internal void RemoveCustomTiming(string category, CustomTiming customTiming)
 {
     GetCustomTimingList(category).Remove(customTiming);
 }
Пример #4
0
 /// <summary>
 /// Adds <paramref name="customTiming"/> to this <see cref="Timing"/> step's dictionary of
 /// custom timings, <see cref="CustomTimings"/>.  Ensures that <see cref="CustomTimings"/> is created,
 /// as well as the <paramref name="category"/>'s list.
 /// </summary>
 /// <param name="category">The kind of custom timing, e.g. "http", "redis", "memcache"</param>
 /// <param name="customTiming">Duration and command information</param>
 public void AddCustomTiming(string category, CustomTiming customTiming)
 {
     GetCustomTimingList(category).Add(customTiming);
 }