For this benchmark, I compared six different methods of checking a value to see if it is numeric:
The test system is a Dell Inspiron 8500 with a Pentium 4-M 2.2GHz CPU, 1GB DDR PC2100 RAM, and 40GB 5400RPM IDE HD. The application was built and runs on version 1.1 of the .NET Framework, optimized and without debugging information (default Release configuration in VS.NET). The test involves calling each method 100,000 times using the given input, clocking the start and end time, and extracting the elapsed time in seconds. I ran two tests for each method, one using input of a valid decimal number (Figure 1) and one using an input of an invalid string containing both numerals and letters (Figure 2). Please feel free to download the source and run benchmarks on your own machines.
User Comments