Пример #1
0
        public static void WriteStudents(string path, IEnumerable <Stud> studs)
        {
            var saveWidth = Lentele.tableWidth;

            Lentele.tableWidth = 120;

            System.IO.StreamWriter file;
            try
            {
                file = new System.IO.StreamWriter(path);
            }
            catch (Exception)
            {
                return;
            }

            file.WriteLine(Lentele.GetFormatRow(false, "Pavarde", "Vardas", "ND1", "ND2", "ND3", "ND4", "ND5"));

            foreach (var stud in studs)
            {
                file.WriteLine(Lentele.GetFormatRow(false, stud.GetData(Stats.Grades)));
            }

            file.Close();
            Lentele.tableWidth = saveWidth;
        }
Пример #2
0
        public static void IvestiStudentus()
        {
            var studentai = new List <Stud>();

            string line;

            while (true)
            {
                Console.WriteLine("Iveskite varda, pavarde ir studento pazymius (ARBA xN kur N yra norimu pazymiu skaicius)");
                Console.WriteLine("ARBA spauskite enter");

                line = Console.ReadLine();

                if (line.Equals(""))
                {
                    break;
                }
                else
                {
                    studentai.Add(new Stud(line));
                }
            }

            Console.WriteLine("Iveskite m (mean) arba me (mediana)");
            line = Console.ReadLine();

            Stats option = Stats.Mean; //1 mean, 2 mediana

            if (line.ToLower().Equals("me"))
            {
                option = Stats.Median;
            }

            Lentele.PrintStudentList(studentai, option);
        }
Пример #3
0
        public static void RunContainerBenchmark(int size)
        {
            Lentele.tableWidth = 80;

            System.Console.WriteLine($"Student list size: {size}");
            System.Console.WriteLine(Lentele.GetFormatRow(false, "Container", "Init", "Split", "Sort", "Write"));
            System.Console.WriteLine(Lentele.GetLine());

            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestList(size)).Prepend("List").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestLinkedListLast(size)).Prepend("LinkedList").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestQueueElementAt(size)).Prepend("Queue").ToArray()));
        }
Пример #4
0
        public static void RunAdvanceBenchmark(int size)
        {
            Lentele.tableWidth = 100;

            System.Console.WriteLine($"Student list size: {size}");
            System.Console.WriteLine(Lentele.GetFormatRow(false, "Strategy", "Init", "Split", "Sort", "Write"));
            System.Console.WriteLine(Lentele.GetLine());

            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestList(size)).Prepend("List/NoDel").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestListDel(size)).Prepend("List/WithDel").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestLinkedListFirst(size)).Prepend("LinkedList/DelFirst").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestLinkedListLast(size)).Prepend("LinkedList/DelLast").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestQueue(size)).Prepend("Queue/First").ToArray()));
            System.Console.WriteLine(Lentele.GetFormatRow(false, FormatTimeSpans(TestQueueElementAt(size)).Prepend("Queue/ElementAt").ToArray()));
        }
Пример #5
0
        public static void IvestiStudentuFaila()
        {
            var studentai = new List <Stud>();

            while (true)
            {
                Console.WriteLine("Iveskite kelia i faila");
                var line = Console.ReadLine().Replace("\"", "");

                if (System.IO.File.Exists(line))
                {
                    studentai = NuskaitytiFaila(line);
                    break;
                }
                else
                {
                    Console.WriteLine("Blogas kelias i faila.");
                }
            }

            Lentele.PrintStudentList(studentai, Stats.All);
        }
Пример #6
0
        public static void RunBenchmark()
        {
            Lentele.tableWidth = 80;

            var sizes = new List <int>()
            {
                1000, 10000, 100000, 1000000, 10000000
            };

            System.Console.WriteLine(Lentele.GetFormatRow(false, "Stud sk", "Init", "Split", "Sort", "Write #1", "Write #2"));
            System.Console.WriteLine(Lentele.GetLine());
            foreach (var i in sizes)
            {
                var times = ExecuteBencmark(i);

                var data = new List <string>()
                {
                    $"{i}"
                };
                data.AddRange(FormatTimeSpans(times));
                System.Console.WriteLine(Lentele.GetFormatRow(false, data.ToArray()));
            }
        }