Beispiel #1
0
        static void Main(string[] args)
        {
            const int textVLen = 100;
              const int patternVLen = 2;

              var encoder = new ByteStringEncoder();
              var operationTimeTester = new OperationTimeTester();

              var text = GetByte2DArray(@"..\doc\Text2D.t", textVLen);
              var pattern = GetByte2DArray(@"..\doc\Pattern2D.t", patternVLen);
              var patternString = encoder.GetStringTo2DArray(pattern);
              var patternSize = string.Format("{0}x{1}", pattern.GetLength(0), pattern.GetLength(1));
              var textSize = string.Format("{0}x{1}", text.GetLength(0), text.GetLength(1));

              var brute = new Brute2DPatternSearcher();
              var result = operationTimeTester.Test(brute.Search, pattern, text);
              Show("Text", textSize, "Brute", patternString, patternSize, result);

              var rabinkarp2DModulo13 = new RabinKarp2DPatternSearcher(new HashingService(256, 13));
              result = operationTimeTester.Test(rabinkarp2DModulo13.Search, pattern, text);
              Show("Text", textSize, "Rabin-Karp 2D with hashing modulo 13", patternString, patternSize, result);

              var rabinkarp2DModulo101 = new RabinKarp2DPatternSearcher(new HashingService(256, 101));
              result = operationTimeTester.Test(rabinkarp2DModulo101.Search, pattern, text);
              Show("Text", textSize, "Rabin-Karp 2D with hashing modulo 101", patternString, patternSize, result);

              var rabinkarp2DModulo2147483647 = new RabinKarp2DPatternSearcher(new HashingService(256, 2147483647));
              result = operationTimeTester.Test(rabinkarp2DModulo2147483647.Search, pattern, text);
              Show("Text", textSize, "Rabin-Karp 2D with hashing modulo 2147483647", patternString, patternSize, result);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var operationTimeTester = new OperationTimeTester();

              var list = new List<int>() {554, 842, 5, 73, 19, 29, 23, 43, 3, 6, 8, 12, 9, 42, 22, 123, 2, 444, 53, 555, 77, 31, 676, 66, 232, 98, 99, 44, 47, 110, 230, 1009, 999, 87, 84, 333, 332, 1004, 1007, 1006, 1009, 1008 };
              var list2 = new List<int>();
              for (int i = 1; i < 10000; i++)
              {
            list2.Add(i);
              }
              list = list2;

              var resultSkipListInsert = operationTimeTester.Test(InsertIntoSkipList, list);
              System.Console.Out.WriteLine("Elapsed: {0}", resultSkipListInsert.Elapsed);
              var resultSkipListFind = operationTimeTester.Test(resultSkipListInsert.OperationResult.Find, 123);
              System.Console.Out.WriteLine("Find result: {0}", resultSkipListFind.OperationResult.Result);
              System.Console.Out.WriteLine("Comparisons: {0}", resultSkipListFind.OperationResult.ComparisonsCount);
              System.Console.Out.WriteLine("Elapsed: {0}", resultSkipListFind.Elapsed);
              System.Console.Out.WriteLine("Remove");
              var resultSkipListRemove = operationTimeTester.Test(resultSkipListInsert.OperationResult.Remove, 123);
              System.Console.Out.WriteLine("Comparisons: {0}", resultSkipListRemove.OperationResult);
              System.Console.Out.WriteLine("Elapsed: {0}", resultSkipListRemove.Elapsed);
              System.Console.Out.WriteLine();
              System.Console.Out.WriteLine();
              var resultTreeInsert = operationTimeTester.Test(InsertIntoTree, list);
              System.Console.Out.WriteLine("Elapsed: {0}", resultTreeInsert.Elapsed);
              var resultTreeFind = operationTimeTester.Test(resultTreeInsert.OperationResult.Find, 123);
              System.Console.Out.WriteLine("Find result: {0}", resultTreeFind.OperationResult.Result.Value == 123);
              System.Console.Out.WriteLine("Comparisons: {0}", resultTreeFind.OperationResult.ComparisonsCount);
              System.Console.Out.WriteLine("Elapsed: {0}", resultTreeFind.Elapsed);
              System.Console.Out.WriteLine("Remove");
              var resultTreeRemove = operationTimeTester.Test(resultTreeInsert.OperationResult.Remove, 123);
              System.Console.Out.WriteLine("Comparisons: {0}", resultTreeRemove.OperationResult);
              System.Console.Out.WriteLine("Elapsed: {0}", resultTreeRemove.Elapsed);

              System.Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var encoder = new ByteStringEncoder();
              var operationTimeTester = new OperationTimeTester();

              var text = File.ReadAllBytes(@"..\doc\pan_wolodyjowski_line_kopia.t");
              var pattern = File.ReadAllBytes(@"..\doc\Pattern_kopia.t");
              var patternString = encoder.GetString(pattern);
              var patternSize = pattern.Length;
              var textSize = text.Length;

              var brute = new BrutePatternSearcher();
              var result = operationTimeTester.Test(brute.Search, pattern, text);
              Show("Pan Wołodyjowski", textSize, "Brute", patternString, patternSize, result);

              Pause();

              var rabinkarpModulo13 = new RabinKarpPatternSearcher(new HashingService(256, 13));
              result = operationTimeTester.Test(rabinkarpModulo13.Search, pattern, text);
              Show("Pan Wołodyjowski", textSize, "Rabin-Karp with hashing modulo 13", patternString, patternSize, result);

              Pause();

              var rabinkarpModulo101 = new RabinKarpPatternSearcher(new HashingService(256, 101));
              result = operationTimeTester.Test(rabinkarpModulo101.Search, pattern, text);
              Show("Pan Wołodyjowski", textSize, "Rabin-Karp with hashing modulo 101", patternString, patternSize, result);

              Pause();

              var rabinkarpModulo2147483647 = new RabinKarpPatternSearcher(new HashingService(256, 2147483647));
              result = operationTimeTester.Test(rabinkarpModulo2147483647.Search, pattern, text);
              Show("Pan Wołodyjowski", textSize, "Rabin-Karp with hashing modulo 2147483647", patternString, patternSize, result);

              Pause();

              var suffixTree = new SuffixTree(text);
              System.Console.Out.WriteLine("Suffix tree building start...");
              var suffixTreeBuildingResult = operationTimeTester.Test(suffixTree.Initialize);
              System.Console.Out.WriteLine("Comparisons count: {0}", suffixTreeBuildingResult.OperationResult);
              System.Console.Out.WriteLine("Suffix tree building finished.");
              System.Console.Out.WriteLine("Elapsed: {0}", suffixTreeBuildingResult.Elapsed);
              System.Console.Out.WriteLine();

              Pause();

              result = operationTimeTester.Test(suffixTree.Find, pattern);
              Show("Pan Wołodyjowski", textSize, "Suffix Tree", patternString, patternSize, result);

              Pause();

              var suffixArray = new SuffixArray(text);
              System.Console.Out.WriteLine("Suffix array building start...");
              var suffixArrayBuildingResult = operationTimeTester.Test(suffixArray.Initialize);
              System.Console.Out.WriteLine("Comparisons count: {0}", suffixArrayBuildingResult.OperationResult);
              System.Console.Out.WriteLine("Suffix array building finished.");
              System.Console.Out.WriteLine("Elapsed: {0}", suffixArrayBuildingResult.Elapsed);
              System.Console.Out.WriteLine();

              Pause();

              result = operationTimeTester.Test(suffixArray.Find, pattern);
              Show("Pan Wołodyjowski", textSize, "Suffix Array", patternString, patternSize, result);

              Pause();
        }