private void TestQuickSortLoop(int len, int rep) { try { m_stopwatch.Stop(); m_stopwatch.Reset(); for (int r = 0; r < rep; r++) { double[] p = ILMath.rand(1, len).m_data; m_stopwatch.Start(); ILQuickSort.QuickSortAscSolid_IT(p, 0, len - 1, 1); m_stopwatch.Stop(); if (!ILMath.IsSorted(p, false)) { throw new Exception("unsorted values detected (asc). Size: " + p.Length); } // descending ILQuickSort.QuickSortDescSolid_IT(p, 0, len - 1, 1); if (!ILMath.IsSorted(p, true)) { throw new Exception("unsorted values detected (desc). Size: " + p.Length); } } Success(" elapsed: " + m_stopwatch.ElapsedMilliseconds + " ms"); } catch (Exception e) { Error(0, e.Message); } }
private void TestQuickSort(double[] p) { int errCode = 0; try { m_stopwatch.Reset(); ILQuickSort.QuickSortAscSolid_IT(p, 0, p.Length - 1, 1); m_stopwatch.Stop(); if (!ILMath.IsSorted(p, false)) { throw new Exception("unsorted values detected. Size: " + p.Length); } Success(); } catch (Exception e) { Error(errCode, e.Message); } }