Пример #1
0
        static void MeasureTimeOnLinkedList(LinkedList <char> text, LinkedList <char> pattern, Series series)
        {
            KMPonLinkedLIst.KMPsearchList(text, pattern);
            var watch       = new Stopwatch();
            var repetitions = 10;

            watch.Start();
            for (int i = 0; i < repetitions; i++)
            {
                KMPonLinkedLIst.KMPsearchList(text, pattern);
            }
            watch.Stop();
            series.Points.Add(new DataPoint(text.Count, (float)watch.ElapsedMilliseconds / repetitions));
        }
Пример #2
0
        // посчитать итерации для списка
        static void MeasureIterationOnList(Series series)
        {
            var strings  = File.ReadAllText("Text.TXT").Split('\n');
            var patterns = File.ReadAllText("Patterns.TXT").Split('\n');

            for (int i = 0; i < strings.Length; i++)
            {
                var list = new LinkedList <char>();
                for (int j = 0; j < strings[i].Length; j++)
                {
                    list.AddLast(strings[i][j]);
                }
                var listpattern = new LinkedList <char>();
                for (int j = 0; j < patterns[i].Length; j++)
                {
                    listpattern.AddLast(patterns[i][j]);
                }
                GC.Collect();
                KMPonLinkedLIst.KMPsearchList(list, listpattern);
                series.Points.Add(new DataPoint(list.Count, KMPonLinkedLIst.iteration));
            }
        }