コード例 #1
0
        public static void PrintStudentList(List <Stud> studentai, Stats option)
        {
            try
            {
                var temp = Studentai.OrderStudents(studentai).ToList();
                studentai = temp;
            }
            finally { }

            PrintLine();
            var row = new string[] { "Pavarde", "Vardas" };

            if (option == Stats.Mean || option == Stats.All)
            {
                row = row.Append("Galutinis (Vid.)").ToArray();
            }
            if (option == Stats.Median || option == Stats.All)
            {
                row = row.Append("Galutinis (Med.)").ToArray();
            }

            PrintRow(row);
            PrintLine();
            foreach (var stud in studentai)
            {
                PrintRow(stud.GetData(option));
                //PrintLine();
            }
        }
コード例 #2
0
        public static List <TimeSpan> ExecuteBencmark(int n)
        {
            var times = new List <TimeSpan>();
            var sw    = new System.Diagnostics.Stopwatch();

            sw.Start();

            var stud = new List <Stud>();

            for (int i = 0; i < n; i++)
            {
                stud.Add(new Stud($"Vardas{i} Pavarde{i} x5"));
            }

            times.Add(sw.Elapsed);
            sw.Restart();

            var v = new List <Stud>();
            var k = new List <Stud>();

            for (int i = 0; i < n; i++)
            {
                if (stud[i].GetMean() < 5)
                {
                    v.Add(stud[i]);
                }
                else
                {
                    k.Add(stud[i]);
                }
            }

            times.Add(sw.Elapsed);
            sw.Restart();

            v = Studentai.OrderStudents(v).ToList();
            k = Studentai.OrderStudents(k).ToList();

            times.Add(sw.Elapsed);
            sw.Restart();

            string path = System.IO.Path.GetTempFileName();

            Studentai.WriteStudents(path, v);
            System.IO.File.Delete(path);

            times.Add(sw.Elapsed);
            sw.Restart();

            path = System.IO.Path.GetTempFileName();
            Studentai.WriteStudents(path, k);
            System.IO.File.Delete(path);

            times.Add(sw.Elapsed);

            return(times);
        }
コード例 #3
0
        public static List <TimeSpan> TestListDel(int size)
        {
            var times = new List <TimeSpan>();
            var sw    = new System.Diagnostics.Stopwatch();

            sw.Start();

            var container = new List <Stud>();

            for (int i = 0; i < size; i++)
            {
                container.Add(new Stud($"Vardas{i} Pavarde{i} x5"));
            }

            times.Add(sw.Elapsed);
            sw.Restart();

            var a = new List <Stud>();
            var b = new List <Stud>();

            for (int i = size - 1; i >= 0; i--)
            {
                if (container[i].GetMean() < 5)
                {
                    a.Add(container[i]);
                }
                else
                {
                    b.Add(container[i]);
                }
                container.RemoveAt(i);
            }

            times.Add(sw.Elapsed);
            sw.Restart();

            a = Studentai.OrderStudents(a).ToList();
            b = Studentai.OrderStudents(b).ToList();

            times.Add(sw.Elapsed);
            sw.Restart();

            string path = System.IO.Path.GetTempFileName();

            Studentai.WriteStudents(path, container);
            System.IO.File.Delete(path);

            times.Add(sw.Elapsed);
            sw.Restart();

            return(times);
        }
コード例 #4
0
        public static List <TimeSpan> TestLinkedListLast(int size)
        {
            var times = new List <TimeSpan>();
            var sw    = new System.Diagnostics.Stopwatch();

            sw.Start();

            var container = new LinkedList <Stud>();

            for (int i = 0; i < size; i++)
            {
                container.AddLast(new Stud($"Vardas{i} Pavarde{i} x5"));
            }

            times.Add(sw.Elapsed);
            sw.Restart();

            var a = new LinkedList <Stud>();
            var b = new LinkedList <Stud>();

            for (int i = 0; i < size; i++)
            {
                var element = container.Last();
                if (element.GetMean() < 5)
                {
                    a.AddLast(element);
                }
                else
                {
                    b.AddLast(element);
                }
                container.RemoveLast();
            }

            times.Add(sw.Elapsed);
            sw.Restart();
            a = new LinkedList <Stud>(Studentai.OrderStudents(a));
            b = new LinkedList <Stud>(Studentai.OrderStudents(b));
            times.Add(sw.Elapsed);
            sw.Restart();

            string path = System.IO.Path.GetTempFileName();

            Studentai.WriteStudents(path, container);
            System.IO.File.Delete(path);

            times.Add(sw.Elapsed);

            return(times);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Iveskite funkcijos numeri (ir spauskite enter):");
                Console.WriteLine("1. Ivesite studentu duomenis");
                Console.WriteLine("2. Ivesite duomenu faila");
                Console.WriteLine("3. Atlikti benchmark'a");
                Console.WriteLine("4. Atlikti konteineriu benchmark'a");
                Console.WriteLine("5. Atlikti 2 strategiju benchmark'a");
                Console.WriteLine("E. Baigti programa");

                var line = Console.ReadLine();

                if (line.Equals("1"))
                {
                    Studentai.IvestiStudentus();
                }
                if (line.Equals("2"))
                {
                    Studentai.IvestiStudentuFaila();
                }
                if (line.Equals("3"))
                {
                    Benchmark.RunBenchmark();
                }
                if (line.Equals("4"))
                {
                    Benchmark.RunContainerBenchmark(100000);
                }
                if (line.Equals("5"))
                {
                    Benchmark.RunAdvanceBenchmark(100000);
                }
                if (line.ToLower().Equals("e"))
                {
                    break;
                }
            }
        }