示例#1
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();

            DateTime now = DateTime.Now;

            if (ConfigurationHelper.LoadPureProfilerConfigurationSection().EnableUtcTime)
            {
                now = DateTime.UtcNow;
            }

            _timingSession = new TimingSession(this, name, tags)
            {
                Started = now
            };
            var rootTiming = new ProfilingStep(this, "root", null);

            _timingSession.AddTiming(rootTiming);
        }
示例#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);
        }