SHARE
TWEET

Parse Performance Test

a guest May 29th, 2010 92 Never
  1. long l;
  2. string strLong = "1";
  3.  
  4. Stopwatch s = new Stopwatch();
  5. s.Start();
  6. for(int i = 0; i < 10000000; i++) {
  7.         long.TryParse(strLong, out l);
  8. }
  9. s.Stop();
  10. s.ElapsedMilliseconds.Dump("Try Parse:");
  11. s.Restart();
  12. for(int i = 0; i < 10000000; i++) {
  13.         long.Parse(strLong);
  14. }
  15. s.ElapsedMilliseconds.Dump("Parse:");
RAW Paste Data
Top