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 TestPerformance() { string obj = "hello world"; int numElems = 1000000; int numTrials = 5; for (int trial = 0; trial < numTrials; trial++) { System.GC.Collect(); { AList <string> arrayList = new AList <string>(); StopWatch sw = new StopWatch(); sw.Start(); for (int i = 0; i < numElems; i++) { arrayList.AddItem(obj); } System.Console.Out.WriteLine(" ArrayList " + sw.Now(TimeUnit.Milliseconds)); } // test ChunkedArrayList System.GC.Collect(); { ChunkedArrayList <string> chunkedList = new ChunkedArrayList <string>(); StopWatch sw = new StopWatch(); sw.Start(); for (int i = 0; i < numElems; i++) { chunkedList.AddItem(obj); } System.Console.Out.WriteLine("ChunkedArrayList " + sw.Now(TimeUnit.Milliseconds)); } } }
public virtual void Run() { StopWatch sw = new StopWatch(); IDictionary <string, JvmPauseMonitor.GcTimes> gcTimesBeforeSleep = this._enclosing .GetGcTimes(); while (this._enclosing.shouldRun) { sw.Reset().Start(); try { Thread.Sleep(JvmPauseMonitor.SleepIntervalMs); } catch (Exception) { return; } long extraSleepTime = sw.Now(TimeUnit.Milliseconds) - JvmPauseMonitor.SleepIntervalMs; IDictionary <string, JvmPauseMonitor.GcTimes> gcTimesAfterSleep = this._enclosing. GetGcTimes(); if (extraSleepTime > this._enclosing.warnThresholdMs) { ++this._enclosing.numGcWarnThresholdExceeded; JvmPauseMonitor.Log.Warn(this._enclosing.FormatMessage(extraSleepTime, gcTimesAfterSleep , gcTimesBeforeSleep)); } else { if (extraSleepTime > this._enclosing.infoThresholdMs) { ++this._enclosing.numGcInfoThresholdExceeded; JvmPauseMonitor.Log.Info(this._enclosing.FormatMessage(extraSleepTime, gcTimesAfterSleep , gcTimesBeforeSleep)); } } this._enclosing.totalGcExtraSleepTime += extraSleepTime; gcTimesBeforeSleep = gcTimesAfterSleep; } }