public void MeasureIndirectStartStopWithUnderplayAndOverplay02()
        {
            var        p1      = new Startwatch();
            Startwatch measure = p1.CreateSibling();
            var        c2      = measure.CreateChild();
            var        c3      = c2.CreateLastSibling(measure);

            Stopwatch assertComparisonTimer = null;
            var       loopTimer             = Stopwatch.StartNew();

            while (loopTimer.ElapsedTicks < 3 * Stopwatch.Frequency)
            {
                if (assertComparisonTimer == null && loopTimer.ElapsedTicks > Stopwatch.Frequency)
                {
                    p1.Stop();
                    assertComparisonTimer = Stopwatch.StartNew();
                    c2.Stop();
                }
                else if (loopTimer.ElapsedTicks > 2 * Stopwatch.Frequency)
                {
                    assertComparisonTimer.Stop();
                    c3.Stop();
                }
            }
            AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure);
        }
 public void TestLastSiblingParentNotNull()
 {
     try {
         var stopwatch   = new Startwatch();
         var child       = stopwatch.CreateChild();
         var lastSibling = child.CreateLastSibling(null);
         Assert.Fail("Expected an exception to be thrown before reaching here");
     }
     catch (ArgumentNullException eError) {
         Assert.AreEqual("parent", eError.ParamName, "parameter name of exception");
     }
 }
        public void MeasureChild()
        {
            var        assertComparisonTimer = Stopwatch.StartNew();
            var        parent    = new Startwatch();
            Startwatch measure   = parent.CreateChild();
            var        loopTimer = Stopwatch.StartNew();

            while (loopTimer.ElapsedTicks < Stopwatch.Frequency)
            {
                ;
            }
            measure.Stop(); assertComparisonTimer.Stop();
            AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure);
        }
        public void MeasureLastSibling01()
        {
            var        first   = new Startwatch();
            var        second  = first.CreateChild();
            Startwatch measure = second.CreateLastSibling(first);
            var        assertComparisonTimer = Stopwatch.StartNew();

            second.Stop();
            var loopTimer = Stopwatch.StartNew();

            while (loopTimer.ElapsedTicks < Stopwatch.Frequency)
            {
                ;
            }
            measure.Stop(); assertComparisonTimer.Stop();
            AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure);
        }
        public void MeasureLastSiblingWithOverplay()
        {
            var        first   = new Startwatch();
            var        second  = first.CreateChild();
            Startwatch measure = second.CreateLastSibling(first);
            var        assertComparisonTimer = Stopwatch.StartNew();

            second.Stop();
            var loopTimer = Stopwatch.StartNew();

            while (loopTimer.ElapsedTicks < 2 * Stopwatch.Frequency)
            {
                if (loopTimer.ElapsedTicks > Stopwatch.Frequency)
                {
                    // checking first.stop() stops measure
                    first.Stop(); assertComparisonTimer.Stop();
                }
            }
            AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure);
        }
Beispiel #6
0
        public void MeasureLastSiblingWithOverplay01()
        {
            var        first   = new Startwatch();
            var        second  = first.CreateChild();
            Startwatch measure = second.CreateLastSibling(first);
            var        assertComparisonTimer = Stopwatch.StartNew();

            second.Stop();
            var loopTimer = Stopwatch.StartNew();

            while (loopTimer.ElapsedTicks < 2 * Stopwatch.Frequency)
            {
                if (loopTimer.ElapsedTicks > Stopwatch.Frequency)
                {
                    using (measure.CreateController()) {} // this is kind of contrived...
                    assertComparisonTimer.Stop();
                }
            }
            AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure);
        }
Beispiel #7
0
        public void MeasureLastSibling02()
        {
            var        first   = new Startwatch();
            var        second  = first.CreateChild();
            Startwatch measure = second.CreateLastSibling(first);
            var        assertComparisonTimer = Stopwatch.StartNew();

            second.Stop();
            var loopTimer = Stopwatch.StartNew();

            using (first.CreateController()) {
                while (loopTimer.ElapsedTicks < Stopwatch.Frequency)
                {
                    ;
                }
                // checking first.stop() stops measure
            }
            assertComparisonTimer.Stop();
            AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure);
        }