Beispiel #1
0
        public void TestMethod1()
        {
            string[] lines = File.ReadAllLines("input1.txt");
            double   res;
            OneList  list = new OneList(lines);
            string   show = list.Show();

            if (list.Length > 0)
            {
                res = list.Sum_Calculation(x: 10);
                res = list.Sum_Calculation(x: 3);
                res = list.Sum_Calculation(x: 0);
            }

            lines = File.ReadAllLines("input2.txt");
            list  = new OneList(lines);
            show  = list.Show();
            if (list.Length > 0)
            {
                res = list.Sum_Calculation(x: 10);
                res = list.Sum_Calculation(x: 3);
                res = list.Sum_Calculation(x: 0);
            }

            lines = File.ReadAllLines("input3.txt");
            list  = new OneList(lines);
            show  = list.Show();
            if (list.Length > 0)
            {
                res = list.Sum_Calculation(x: 10);
                res = list.Sum_Calculation(x: 3);
                res = list.Sum_Calculation(x: 0);
            }

            lines = File.ReadAllLines("input4.txt");
            list  = new OneList(lines);
            show  = list.Show();
            if (list.Length > 0)
            {
                res = list.Sum_Calculation(x: 10);
                res = list.Sum_Calculation(x: 3);
                res = list.Sum_Calculation(x: 0);
            }

            lines = File.ReadAllLines("input5.txt");
            list  = new OneList(lines);
            show  = list.Show();
            if (list.Length > 0)
            {
                res = list.Sum_Calculation(x: 10);
                res = list.Sum_Calculation(x: 3);
                res = list.Sum_Calculation(x: 0);
            }
        }
Beispiel #2
0
        public void TestMethod1()
        {
            OneList list  = new OneList(5);
            int     index = 0;
            Point   point = null;

            point = list.Search(1);
            point = list.Search(5);
            point = list.Search(6);
            point = list.Search(3);
            index = list.Search(new Point(1));
            index = list.Search(new Point(5));
            index = list.Search(new Point(6));
            index = list.Search(new Point(3));
            index = list.Search(new Point(4));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Word");
            int        n      = 10000;
            Random     rnd    = new Random();
            int        search = rnd.Next(0, n);
            List <int> List   = new List <int>();
            OneList    List1  = new OneList();

            for (int i = 1; i <= n; i++)
            {
                List.Add(i);
                List1.Add(i);
                //Console.Write(List1 + " ");
            }
            foreach (int item in List1)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine("\n");
            Console.WriteLine("List statistic:\n");
            Console.WriteLine("Search key: " + search);
            Console.WriteLine("\nBasic Search:\n");
            Stopwatch bsw    = Stopwatch.StartNew();
            int       bfound = List1.Element(search);

            bsw.Stop();
            Console.WriteLine("Found key: " + List1.Element(search));
            Console.WriteLine("Elapsed time : " + bsw.Elapsed);
            Console.WriteLine("\nBinary Search:\n");
            Stopwatch sw    = Stopwatch.StartNew();
            int       found = BinSearch(List1, search);

            sw.Stop();
            Console.WriteLine("Found key: " + BinSearch(List1, search));
            Console.WriteLine("Elapsed time : " + sw.Elapsed);
            //Console.WriteLine(List1.Element(26));

            Console.WriteLine("\nPress any key to Exit");
            Console.ReadKey();
        }
Beispiel #4
0
        static int BinSearch(OneList List, int key)
        {
            int left  = 0;
            int mid   = 0;
            int right = List.Count();

            while (!(left >= right))
            {
                mid = left + (right - left) / 2;
                if (List.Element(mid) == key)
                {
                    return(mid);
                }
                if (List.Element(mid) > key)
                {
                    right = mid;
                }
                else
                {
                    left = mid;
                }
            }
            return(-(1 + left));
        }
Beispiel #5
0
        public void TestMethod1()
        {
            OneList list  = new OneList(5);
            int     index = list.Search(new Point(5));

            list.Add(new Point(1));
            list.Add(new Point(2));
            list.Add(new Point(10));
            list.Add(new Point(6));

            list.Remove(1);
            list.Remove(6);
            list.Remove(10);
            list.Remove(0);
            list.Remove(2);
            list.Remove(3);
            list.Remove(1);
            list.Remove(1);
            list.Remove(2);
            list.Remove(1);
            list.Remove(1);
            list.Remove(1);

            list = new OneList(5);

            list.Add(new Point(1));
            list.Add(new Point(2));
            list.Add(new Point(10));
            list.Add(new Point(6));

            list.Remove(new Point(1));
            list.Remove(new Point(11));
            list.Remove(new Point(10));
            list.Remove(new Point(2));
            list.Remove(new Point(3));
            list.Remove(new Point(4));
            list.Remove(new Point(5));
            list.Remove(new Point(6));
            list.Remove(new Point(1));
            list.Remove(new Point(4));
            list.Remove(new Point(2));
            list.Remove(new Point(1));
            list.Search(new Point(1));
            Point point = list.Search(1);

            list.Add(new Point(2));
            list.Add(new Point(10));
            list.Add(new Point(6));
            list.Add(new Point(1));

            point = list.Search(1);
            point = list.Search(0);
            point = list.Search(10);
            point = list.Search(4);
            point = list.Search(3);

            index = list.Search(new Point(1));
            index = list.Search(new Point(11));
            index = list.Search(new Point(2));
            string output = list.Show();
        }
Beispiel #6
0
        private models.Run Iteration(string benchmark, int iteration, bool isDryRun)
        {
            var dryRun = isDryRun ? " dryrun" : "";

            Logging.GetLogging().InfoFormat("Benchmarker | Benchmark{0} \"{1}\": start iteration {2}", dryRun, benchmark, iteration);
            GC.Collect(1);
            System.Threading.Thread.Sleep(5 * 1000);              // cool down?

            var sw = Stopwatch.StartNew();

            switch (benchmark)
            {
            case "bh":
                BH.Main(new string[] { "-b", "400", "-s", "200" }, Logging.GetLogging());
                break;

            case "binarytree":
                BinaryTrees.Main(new string[] { "17" }, Logging.GetLogging());
                break;

            case "bisort":
                BiSort.Main(new string[] { "-s", "1500000" }, Logging.GetLogging());
                break;

            case "euler":
                Euler.Main(new string[] { }, Logging.GetLogging());
                break;

            case "except":
                except.Main(new string[] { "500000" }, Logging.GetLogging());
                break;

            case "gcbridge-links":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-linkedfan":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-inversefan":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-deadlist":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-selflinks":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-spider":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-doublefan-1000":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "gcbridge-doublefan-4000":
                GcBridge.Main(new string[] { benchmark }, Logging.GetLogging());
                break;

            case "grandetracer":
                RayTracer.Main(new string[] { }, Logging.GetLogging());
                break;

            case "graph4":
                graph4.Node.Main(Logging.GetLogging());
                break;

            case "graph8":
                graph8.Node.Main(Logging.GetLogging());
                break;

            case "hash3":
                Hash3.Main(new string[] { "400000" }, Logging.GetLogging());
                break;

            case "health":
                Health.Main(new string[] { "-l", "10", "-t", "16" }, Logging.GetLogging());
                break;

            case "lists":
                Lists.Main(new string[] { "1000" }, Logging.GetLogging());
                break;

            case "mandelbrot":
                Mandelbrot.Main(new string[] { "1500" }, Logging.GetLogging());
                break;

            case "n-body":
                NBody.Main(new string[] { "400000" }, Logging.GetLogging());
                break;

            case "objinst":
                Objinst.Main(new string[] { "4000000" }, Logging.GetLogging());
                break;

            case "onelist":
                OneList.Main();
                break;

            case "perimeter":
                Perimeter.Main(new string[] { "-l", "17" }, Logging.GetLogging());
                break;

            case "raytracer2":
                RayTracer2.Main(new string[] { "120" }, Logging.GetLogging());
                break;

            case "raytracer3":
                RayTracer3.Main(new string[] { "120" }, Logging.GetLogging());
                break;

            case "scimark-fft":
                ScimarkEntrypoint.Main(new string[] { "fft" }, Logging.GetLogging());
                break;

            case "scimark-sor":
                ScimarkEntrypoint.Main(new string[] { "sor" }, Logging.GetLogging());
                break;

            case "scimark-mc":
                ScimarkEntrypoint.Main(new string[] { "mc" }, Logging.GetLogging());
                break;

            case "scimark-mm":
                ScimarkEntrypoint.Main(new string[] { "mm" }, Logging.GetLogging());
                break;

            case "scimark-lu":
                ScimarkEntrypoint.Main(new string[] { "lu" }, Logging.GetLogging());
                break;

            case "specraytracer":
                MainCL.Main(new string[] { "200", "1250" }, Logging.GetLogging());
                break;

            case "strcat":
                strcat.Main(new string[] { "40000000" });
                break;

            default:
                throw new NotImplementedException();
            }
            sw.Stop();
            Logging.GetLogging().InfoFormat("Benchmarker | Benchmark{0} \"{1}\": finished iteration {2}, took {3}ms", dryRun, benchmark, iteration, sw.ElapsedMilliseconds);
            var run = new models.Run {
                Benchmark = new models.Benchmark {
                    Name = benchmark
                }
            };

            run.RunMetrics.Add(
                new models.RunMetric {
                Metric = models.RunMetric.MetricType.Time,
                Value  = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
            }
                );
            return(run);
        }