예제 #1
0
        public void PerformanceComparer()
        {
            var perf = new Stopwatch();
            var opt  = Stopwatch.IsHighResolution;

            var         list      = Enumerable.Range(1, 2000000).ToList();
            IKarateChop chopper   = null;
            int         index     = -1;
            int         searching = 2;

            perf.Start();
            chopper = new RecursionChopper();
            index   = chopper.Chop(searching, list);
            perf.Stop();
            Console.WriteLine(chopper.GetType().Name + " result=" + index + ": " + perf.ElapsedMilliseconds);
            perf.Reset();

            perf.Start();
            chopper = new ProceduralChopper();
            index   = chopper.Chop(searching, list);
            perf.Stop();
            Console.WriteLine(chopper.GetType().Name + " result=" + index + ": " + perf.ElapsedMilliseconds);
            perf.Reset();

            perf.Start();
            chopper = new FunctionalChopper();
            index   = chopper.Chop(searching, list);
            perf.Stop();
            Console.WriteLine(chopper.GetType().Name + " result=" + index + ": " + perf.ElapsedMilliseconds);

            perf.Start();
            chopper = new FunctionalChopper2();
            index   = chopper.Chop(searching, list);
            perf.Stop();
            Console.WriteLine(chopper.GetType().Name + " result=" + index + ": " + perf.ElapsedMilliseconds);
            perf.Reset();

            perf.Start();
            chopper = new MapReduceChopper();
            index   = chopper.Chop(searching, list);
            perf.Stop();
            Console.WriteLine(chopper.GetType().Name + " result=" + index + ": " + perf.ElapsedMilliseconds);
            perf.Reset();

            perf.Start();
            chopper = new BinaryTreeChopper();
            index   = chopper.Chop(searching, list);
            perf.Stop();
            Console.WriteLine(chopper.GetType().Name + " result=" + index + ": " + perf.ElapsedMilliseconds);
        }
예제 #2
0
        public int Procedural_Test(int SearchNumber, List <int> SearchArray)
        {
            var chopper = new ProceduralChopper();

            return(chopper.Chop(SearchNumber, SearchArray));
        }