public virtual void TestExceptions() { StopWatch sw = new StopWatch(); try { sw.Stop(); } catch (Exception e) { Assert.True("IllegalStateException is expected", e is InvalidOperationException ); } sw.Reset(); sw.Start(); try { sw.Start(); } catch (Exception e) { Assert.True("IllegalStateException is expected", e is InvalidOperationException ); } }
public virtual void CommonUsagePerfTest() { int NumRuns = 5; DataChecksum checksum = DataChecksum.NewDataChecksum(DataChecksum.Type.Crc32c, 512 ); int dataLength = 512 * 1024 * 1024; TestDataChecksum.Harness h = new TestDataChecksum.Harness(checksum, dataLength, true ); for (int i = 0; i < NumRuns; i++) { StopWatch s = new StopWatch().Start(); // calculate real checksum, make sure it passes checksum.CalculateChunkedSums(h.dataBuf, h.checksumBuf); s.Stop(); System.Console.Error.WriteLine("Calculate run #" + i + ": " + s.Now(TimeUnit.Microseconds ) + "us"); s = new StopWatch().Start(); // calculate real checksum, make sure it passes checksum.VerifyChunkedSums(h.dataBuf, h.checksumBuf, "fake file", 0); s.Stop(); System.Console.Error.WriteLine("Verify run #" + i + ": " + s.Now(TimeUnit.Microseconds ) + "us"); } }
public virtual void TestStartAndStop() { using (StopWatch sw = new StopWatch()) { NUnit.Framework.Assert.IsFalse(sw.IsRunning()); sw.Start(); Assert.True(sw.IsRunning()); sw.Stop(); NUnit.Framework.Assert.IsFalse(sw.IsRunning()); } }