public void StartTimeWithoutStarting() { var first = new Startwatch(); var second = first.CreateSibling(); AssertDatesSimilar(null, second.StartTime); }
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 StartTimeWithoutStopping() { var stopwatch = new Startwatch(); var dateTime = DateTime.Now; AssertDatesSimilar(dateTime, stopwatch.StartTime); }
public void IsActiveOnInactiveStopwatch() { var watch = new Startwatch(); watch.Stop(); Assert.IsFalse(watch.IsActive, "Stopwatch active property"); }
public void MeasureInactiveStopwatch() { var assertComparisonTimer = new Stopwatch(); var parent = new Startwatch(); var measure = parent.CreateSibling(); AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
public void EndTimeWithStopping() { var stopwatch = new Startwatch(); Thread.Sleep(10); stopwatch.Stop(); var dateTime = DateTime.Now; AssertDatesSimilar(dateTime, stopwatch.EndTime); }
public void AssertStopwatch(long expectedTicks, Startwatch actual, string message, params object[] fmt) { if (expectedTicks + 20000 < actual.ElapsedTicks || expectedTicks - 20000 > actual.ElapsedTicks) { var msg = "Within 10,0000 micro seconds."; if (message != null && fmt != null) { msg += string.Format(message, fmt); } Assert.AreEqual(expectedTicks, actual.ElapsedTicks, msg); } }
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 Test001() { var log = GetLogger(); Startwatch timer = new Startwatch(); log.PerfEvent_Initialize(); timer.Stop(); WasteTime(); Assert.IsFalse(log.PerfEvent_GetSetupTime().TimeData.IsActive, "SEtup timer should not be running"); AssertStopwatch(timer, log.PerfEvent_GetSetupTime().TimeData); }
public void MeasureStandard() { Startwatch measure = new Startwatch(); var assertComparisonTimer = Stopwatch.StartNew(); var loopTimer = Stopwatch.StartNew(); while (loopTimer.ElapsedTicks < Stopwatch.Frequency) { ; } measure.Stop(); assertComparisonTimer.Stop(); AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
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 MeasureStopwatchConstructionFromTicks() { var assertComparisonTimer = Stopwatch.StartNew(); Startwatch measure = null; var loopTimer = Stopwatch.StartNew(); while (loopTimer.ElapsedTicks < Stopwatch.Frequency) { ; } assertComparisonTimer.Stop(); measure = Startwatch.FromTicks(assertComparisonTimer.ElapsedTicks); AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
private void bntStart_Click(object sender, EventArgs e) { if (bntStart.Text == "START") { bntStart.Text = "PAUSE"; Startwatch.Start(); watch.Start(); } else { bntStart.Text = "START"; Startwatch.Stop(); watch.Stop(); } }
public void MeasureStandardWithOverplay() { Startwatch measure = new Startwatch(); var assertComparisonTimer = Stopwatch.StartNew(); var loopTimer = Stopwatch.StartNew(); while (loopTimer.ElapsedTicks < 2 * Stopwatch.Frequency) { if (loopTimer.ElapsedTicks > Stopwatch.Frequency) { measure.Stop(); assertComparisonTimer.Stop(); } } AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
public void test001() { var executionTime = Startwatch.StartNew(); /* execute interesting code here */ System.Threading.Thread.Sleep(new System.Random().Next(10, 20)); executionTime.Stop(); Console.WriteLine("Total Ticks {0}", executionTime.ElapsedTicks); Console.WriteLine("Total Milliseconds {0}", executionTime.ElapsedMilliseconds); Console.WriteLine("Total Timespan {0}", (TimeSpan)executionTime.Elapsed); Console.WriteLine("Start Time {0}", (DateTime?)executionTime.StartTime); Console.WriteLine("End Time {0}", (DateTime?)executionTime.EndTime); }
public void MeasureStandard() { Startwatch measure = new Startwatch(); var assertComparisonTimer = Stopwatch.StartNew(); var loopTimer = Stopwatch.StartNew(); using (measure.CreateController()) { while (loopTimer.ElapsedTicks < Stopwatch.Frequency) { ; } } assertComparisonTimer.Stop(); AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
public void MeasureActiveStopwatchConstructionWithOverplay() { var assertComparisonTimer = Stopwatch.StartNew(); Startwatch measure = Startwatch.FromStopwatch(assertComparisonTimer); var loopTimer = Stopwatch.StartNew(); while (loopTimer.ElapsedTicks < 2 * Stopwatch.Frequency) { if (loopTimer.ElapsedTicks > Stopwatch.Frequency) { assertComparisonTimer.Stop(); measure.Stop(); } } AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
public void Test002() { var log = GetLogger(); log.PerfEvent_Initialize(); Startwatch timer = new Startwatch(); WasteTime(); Assert.IsTrue(log.PerfEvent_GetBeforeFirstEventTime().TimeData.IsActive, "First event timer should be running"); log.PerfEvent_NewEventAudit(_lt); timer.Stop(); WasteTime(); Assert.IsFalse(log.PerfEvent_GetBeforeFirstEventTime().TimeData.IsActive, "Before first event timer should not be runing"); AssertStopwatch(timer, log.PerfEvent_GetBeforeFirstEventTime().TimeData); }
public void MeasureStandardWithOverplay() { Startwatch measure = new Startwatch(); var assertComparisonTimer = Stopwatch.StartNew(); 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); }
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 MeasureSiblingWithOverplay() { var first = new Startwatch(); Startwatch measure = first.CreateSibling(); var assertComparisonTimer = Stopwatch.StartNew(); first.Stop(); var loopTimer = Stopwatch.StartNew(); while (loopTimer.ElapsedTicks < 2 * Stopwatch.Frequency) { if (loopTimer.ElapsedTicks > Stopwatch.Frequency) { measure.Stop(); assertComparisonTimer.Stop(); } } AssertStopwatch(assertComparisonTimer.ElapsedTicks, measure); }
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); }
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); }
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); }
public void Test004() { var log = GetLogger(); log.PerfEvent_Initialize(); Assert.IsFalse(log.PerfEvent_GetRunningTotal().TimeData.IsActive, "Running total timer should not have started yet"); WasteTime(); Startwatch timer = new Startwatch(); log.PerfEvent_NewEventAudit(_lt); Assert.IsTrue(log.PerfEvent_GetRunningTotal().TimeData.IsActive, "Total timer should have started"); WasteTime(); Assert.IsTrue(log.PerfEvent_GetRunningTotal().TimeData.IsActive, "Total timer should have started"); log.PerfEvent_CompleteEverything(); timer.Stop(); WasteTime(); Assert.IsFalse(log.PerfEvent_GetRunningTotal().TimeData.IsActive, "Running total timer should have finished"); AssertStopwatch(timer, log.PerfEvent_GetRunningTotal().TimeData); }
public void Test100NSTicksToTimespan01() { var stopwatch = Startwatch.FromTimeSpanTicks(20000); AssertTimespansClose(new TimeSpan(20000), stopwatch.Elapsed); }
public void TestMillisecondsToTimespan02() { var stopwatch = Startwatch.FromMilliseconds(25 * 1000 + 200); AssertTimespansClose(new TimeSpan(0, 0, 0, 25, 200), stopwatch.Elapsed); }
public void TestMillisecondsToTimespan01() { var stopwatch = Startwatch.FromMilliseconds(20 * 1000); Assert.AreEqual(new TimeSpan(0, 0, 20), stopwatch.Elapsed); }
public void TestTimespanToTimespan03() { var stopwatch = Startwatch.FromTimeSpan(new TimeSpan(0, 0, 0, 5, 150)); AssertTimespansClose(new TimeSpan(0, 0, 0, 5, 150), stopwatch.Elapsed); }
public void TestTimespanToTimespan02() { var stopwatch = Startwatch.FromTimeSpan(new TimeSpan(0, 0, 35)); Assert.AreEqual(new TimeSpan(0, 0, 35), stopwatch.Elapsed); }