Comparison of C # string segmentation efficiency

Source: Internet
Author: User
Split string efficiency compare public        static void Fund ()        {            //1. String. Split method            //a. Byte array:            //625 ms/million            string str1 = "ACABCDEABCDEABCDE";            string[] strArr1 = null;            System.Diagnostics.Stopwatch SW = new System.Diagnostics.Stopwatch ();            Sw. Start ();            for (int i = 0; i < 10000000; i++)            {                strArr1 = str1. Split (new char[1] {' C '});            }            Sw. Stop ();            Console.WriteLine (SW. Elapsedmilliseconds);//in milliseconds            //b. Array of strings            //703 milliseconds/million            string str3 = "ACABCDEABCDEABCDE";            string[] StrArr3 = str3. Split (new string[1] {"CDE"}, Stringsplitoptions.none);            2.regex.split method            //7093 ms/million            string STR4 = "ACABCDEABCDEABCDE";            string[] StrArr4 = Regex.Split (STR4, "CDE");        }

  

Comparison of C # string segmentation efficiency

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.