Beispiel #1
0
        /// <summary>
        /// Start a timer with the given name.
        /// </summary>
        /// <remarks>
        /// <para>Use the returned Timer to stop the interval measurement.</para>
        /// <para>If timing is not enabled, null (no-op) timers will be returend and no time tracking is performed.</para>
        /// </remarks>
        /// <param name="name">The name of the timer instance to start.</param>
        /// <returns>The timer instance that should be stopped when the interval is completed.</returns>
        public ITimer StartTimer(string name)
        {
            ITimer retval = null;

            if (IsTimingEnabled)
            {
                lock (masterTimers)
                {
                    if (!masterTimers.TryGetValue(name, out ITimerMaster master))
                    {
                        master = new TimingMaster(name);
                        masterTimers.Add(name, master);
                    }
                    retval = master.CreateTimer();
                    retval.Start();
                }
            }
            else
            {
                retval = NULL_TIMER;
            }
            return(retval);
        }
Beispiel #2
0
 /// <summary>
 /// Create a new timer with the given master.
 /// </summary>
 /// <param name="master">The timing master to collect our data.</param>
 public TimingTimer(TimingMaster master) : base(master)
 {
 }