Checking the Performance of Enum.GetName vs ToString

            Stopwatch w = new Stopwatch();
            w.Start();
            for (int i = 0; i < 10000; i++)
            {
                string ghouse = Enum.GetName(tableName.GetType(), tableName);
            }

            w.Stop();
            Console.WriteLine("I time  = " + w.ElapsedTicks);
            w.Reset();
            w.Start();
            for (int i = 0; i < 10000; i++)
            {
                string ghouse = tableName.ToString();
            }
            w.Stop();
            Console.WriteLine("II time = " + w.ElapsedTicks);


Output
I time  = 24606
II time = 38881

Comments

Popular posts from this blog

Convert XElement to DataTable

Enable mouse scroll-wheel in VB6

C# code to Check IE Proxy Settings