As you can see in Figure 1, the differences between the six methods are not that dramatic when there is a valid input. I did find that the Regular Expression tended to slow down with larger inputs, but overall, given that these numbers were produced by 100,000 tries, the time required for each and the difference between each is very insignificant. The incremental char search has the clear edge of about one tenth of a second.
In Figure 2, we see the trend take a dramatic turn, with both methods using a catch block increasing over tenfold to around nine seconds, which highlights the extra effort involved in catching exceptions. The other methods are almost identical to their counterparts in the previous test, excepting the Regular Expression, which added a good two tenths of a second. And again, the incremental char search wins out in raw performance by about a tenth of a second. You may be thinking that if there were more valid numbers prior to the invalid chars that it would lose the advantage (since it would short circuit later), but I tested into the trillions with about the same performance.
User Comments