是否需要并行处理?
推荐答案使用秒表类运行一种算法,然后运行另一种算法。
Use Stopwatch class to run one algorithm and then run the other one.
Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); // Code for your algorithm stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);请确保您使用大量输入来测试算法。在小集合上执行比其他算法更快的排序算法,不一定在大集合上执行更快。
Make sure you test your algorithm with numerous size inputs. A sorting algorithm which performs faster than another algorithm on small set may not necessarily perform faster on a larger set.