示例#1
0
        internal void Mark(string stepDescription, int recursion = 0)
        {
            long tickMark = Stopwatch.ElapsedTicks;
            long msMark   = Stopwatch.ElapsedMilliseconds;
            var  tm       = new TimerMark()
            {
                Milliseconds = msMark, Ticks = tickMark, StepDescription = stepDescription
            };

            lock (Marks)
            {
                Marks.Add(tm);
            }
            #region test
            //            if (tm != null)
            //            {
            //                Marks.Add(tm);
            //            }
            //            else
            //            {
            //#if DEBUG
            //                throw new CodeFirstException("Null timer mark");
            //#else
            //                if(recursion < 10)
            //                {
            //                    Mark(stepDescription, recursion++);
            //                }
            //                else
            //                {
            //                    throw new CodeFirstException("Null timer mark - tried 10 times");
            //                }
            //#endif
            //            }
            #endregion
        }
示例#2
0
        internal void End(string stepDescription, int recursion = 0)
        {
            Stopwatch.Stop();
            var tm = new TimerMark()
            {
                Milliseconds = Stopwatch.ElapsedMilliseconds, Ticks = Stopwatch.ElapsedTicks, StepDescription = stepDescription
            };

            lock (Marks)
            {
                Marks.Add(tm);
                Marks = Marks.Select(x => x != null ? x : new TimerMark()
                {
                    StepDescription = "MISSINGNO"
                }).OrderBy(x => x.Ticks).ToList();
            }
            #region test
            //            if (tm != null)
            //            {

            //            }
            //            else
            //            {
            //#if DEBUG
            //                throw new CodeFirstException("Null timer mark");
            //#else
            //                if(recursion < 10)
            //                {
            //                    End(stepDescription, recursion++);
            //                }
            //                else
            //                {
            //                    throw new CodeFirstException("Null timer mark - tried 10 times");
            //                }
            //#endif
            //            }
            #endregion
        }