Click here to Skip to main content
15,920,217 members
Home / Discussions / C#
   

C#

 
AnswerRe: Web Camera Application using C# Pin
Ravi Bhavnani11-May-12 3:25
professionalRavi Bhavnani11-May-12 3:25 
GeneralRe: Web Camera Application using C# Pin
Sentenryu11-May-12 4:41
Sentenryu11-May-12 4:41 
AnswerRe: Web Camera Application using C# Pin
Eddy Vluggen11-May-12 5:46
professionalEddy Vluggen11-May-12 5:46 
GeneralRe: Web Camera Application using C# Pin
Sentenryu11-May-12 6:53
Sentenryu11-May-12 6:53 
AnswerRe: Web Camera Application using C# Pin
Eddy Vluggen11-May-12 8:02
professionalEddy Vluggen11-May-12 8:02 
GeneralRe: Web Camera Application using C# Pin
Sentenryu11-May-12 8:39
Sentenryu11-May-12 8:39 
AnswerRe: Web Camera Application using C# Pin
Ravi Bhavnani11-May-12 9:01
professionalRavi Bhavnani11-May-12 9:01 
GeneralRe: Web Camera Application using C# Pin
Sentenryu11-May-12 9:23
Sentenryu11-May-12 9:23 
GeneralRe: Web Camera Application using C# Pin
Ravi Bhavnani11-May-12 9:25
professionalRavi Bhavnani11-May-12 9:25 
GeneralRe: Web Camera Application using C# Pin
austinwales13-May-12 7:30
austinwales13-May-12 7:30 
GeneralRe: Web Camera Application using C# Pin
Ravi Bhavnani13-May-12 7:41
professionalRavi Bhavnani13-May-12 7:41 
GeneralRe: Web Camera Application using C# Pin
austinwales24-May-12 0:13
austinwales24-May-12 0:13 
QuestionRegex for String.Contains Pin
amrok2amrokk10-May-12 23:09
amrok2amrokk10-May-12 23:09 
AnswerRe: Regex for String.Contains Pin
Abhinav S10-May-12 23:19
Abhinav S10-May-12 23:19 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk10-May-12 23:32
amrok2amrokk10-May-12 23:32 
AnswerRe: Regex for String.Contains Pin
Pete O'Hanlon10-May-12 23:48
mvePete O'Hanlon10-May-12 23:48 
GeneralRe: Regex for String.Contains Pin
Manfred Rudolf Bihy11-May-12 0:28
professionalManfred Rudolf Bihy11-May-12 0:28 
GeneralRe: Regex for String.Contains Pin
PIEBALDconsult11-May-12 3:24
mvePIEBALDconsult11-May-12 3:24 
AnswerRe: Regex for String.Contains Pin
OriginalGriff11-May-12 3:52
mveOriginalGriff11-May-12 3:52 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk11-May-12 4:28
amrok2amrokk11-May-12 4:28 
So I created a simple test and here are the results:
Regex 00:00:00.2968750
String 00:00:00.3281250
It's for release configuration.

C#
namespace RegexTest
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        List<string> _data;

        public Window1()
        {
            InitializeComponent();

            _data = new List<string>(500000);

            Random rand = new Random();
            byte[] data = new byte[4000];

            //int count = _data.Count;

            for (int i = 0; i < 50000; i++)
            {
                rand.NextBytes(data);
                _data.Add(Convert.ToBase64String(data));
            }
        }

        private void buttonTestRegex_Click(object sender, RoutedEventArgs e)
        {
            DateTime start = DateTime.Now;

            Regex regex = new Regex("99");
            int count = _data.Count;
            int match = 0;
            for (int i = 0; i < count; i++)
            {
                if (regex.IsMatch(_data[i]))
                {
                    match++;
                }
            }

            DateTime end = DateTime.Now;

            this.textBoxRegex.Text = (end - start).ToString();
        }

        private void buttonTestString_Click(object sender, RoutedEventArgs e)
        {
            DateTime start = DateTime.Now;

            int count = _data.Count;
            int match = 0;
            for (int i = 0; i < count; i++)
            {
                if (_data[i].Contains("99"))
                {
                    match++;
                }
            }

            DateTime end = DateTime.Now;

            this.textBoxString.Text = (end - start).ToString();
        }
    }
}

GeneralRe: Regex for String.Contains Pin
OriginalGriff11-May-12 4:55
mveOriginalGriff11-May-12 4:55 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk11-May-12 5:07
amrok2amrokk11-May-12 5:07 
GeneralRe: Regex for String.Contains Pin
PIEBALDconsult11-May-12 5:30
mvePIEBALDconsult11-May-12 5:30 
GeneralRe: Regex for String.Contains Pin
amrok2amrokk11-May-12 5:59
amrok2amrokk11-May-12 5:59 
GeneralRe: Regex for String.Contains Pin
PIEBALDconsult11-May-12 5:09
mvePIEBALDconsult11-May-12 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.