Beispiel #1
0
        /// <summary>
        /// Returns an <see cref="System.IDisposable"/> that will ignore the profiling between its creation and disposal.
        /// </summary>
        /// <returns>Returns the created <see cref="System.IDisposable"/> as the ignored step.</returns>
        public virtual IDisposable Ignore()
        {
            IProfilingStep ignoredStep = new ProfilingStep(this, "ignored step", null);

            ignoredStep.Discard();
            return(ignoredStep);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a <see cref="Profiler"/> class instance.
        /// </summary>
        /// <param name="name">The profiler name.</param>
        /// <param name="storage">The profiler storage.</param>
        /// <param name="tags">Tags of the profiler.</param>
        public Profiler(string name, IProfilingStorage storage, TagCollection tags)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            _storage   = storage;
            _stopwatch = new Stopwatch();
            _stopwatch.Start();
            _timingSession = new TimingSession(this, name, tags)
            {
                Started = DateTime.UtcNow
            };
            var rootTiming = new ProfilingStep(this, "root", null);

            _timingSession.AddTiming(rootTiming);
        }