Esempio n. 1
0
 internal PcreMatch(PcreRegex parent, byte[] input, int start, int end, int options)
 {
     _success = true;
     _parent = parent;
     _input = input;
     _start = start;
     _end = end;
     _options = options;
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string str = GenerateRandomDataString(StrLen);

            int i;
            int testNum = 10;
            DateTime start;

            start = DateTime.Now;
            var regex = new PcreRegex("abcd", PcreOptions.NONE, PcreStudyOptions.NONE);
            Console.WriteLine("First creation time: " + (DateTime.Now - start).TotalMilliseconds);
            start = DateTime.Now;
            regex = new PcreRegex("\"id\\d+\"", PcreOptions.NONE, PcreStudyOptions.PCRE_STUDY_JIT_COMPILE);
            Console.WriteLine("JIT creation time: " + (DateTime.Now - start).TotalMilliseconds);
            /*
            var abc = "qwerty \"id5\" qwerty";
            var bca = regex.Replace(abc, "bca");
            */
            start = DateTime.Now;
            for (i = 0; i < testNum; i++)
            {
                regex.Replace(str, "bca");
            }
            Console.WriteLine((DateTime.Now - start).TotalMilliseconds / testNum);

            start = DateTime.Now;
            for (i = 0; i < testNum; i++)
            {
                var a = regex.Matches(str).Count;
            }
            Console.WriteLine((DateTime.Now - start).TotalMilliseconds / testNum);

            start = DateTime.Now;
            for (i = 0; i < testNum; i++)
            {
                Test(regex, str);
            }
            Console.WriteLine((DateTime.Now - start).TotalMilliseconds / testNum);

            start = DateTime.Now;
            var regexOrig = new Regex("abcd", RegexOptions.None);
            Console.WriteLine("First creation time: " + (DateTime.Now - start).TotalMilliseconds);
            start = DateTime.Now;
            regexOrig = new Regex("\"id\\d+\"", RegexOptions.Compiled);
            Console.WriteLine("Second creation time: " + (DateTime.Now - start).TotalMilliseconds);

            start = DateTime.Now;
            for (i = 0; i < testNum; i++)
            {
                regexOrig.Replace(str, "bca");
            }
            Console.WriteLine((DateTime.Now - start).TotalMilliseconds / testNum);

            start = DateTime.Now;
            for (i = 0; i < testNum; i++)
            {
                //regexOrig.Replace(str,"str",)
                var a = regexOrig.Matches(str).Count;
            }
            Console.WriteLine((DateTime.Now - start).TotalMilliseconds / testNum);

            start = DateTime.Now;
            for (i = 0; i < testNum; i++)
            {
                TestOrig(regexOrig, str);
            }
            Console.WriteLine((DateTime.Now - start).TotalMilliseconds / testNum);
            if (args.Length > 0) Console.ReadKey();
        }
Esempio n. 3
0
        private static void Test(PcreRegex regex, string str)
        {
            var match = regex.Match(str);

            while (match.Success)
            {
                //Console.WriteLine(match.Value);
                match = match.NextMatch();
            }
        }