Created
June 18, 2011 13:55
-
-
Save zhangz/1033120 to your computer and use it in GitHub Desktop.
ExceptionTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ExceptionTest | |
| { | |
| long maxLevel = 20; | |
| static void Main(string[] args) | |
| { | |
| ExceptionTest test = new ExceptionTest(); | |
| int count = 10000; | |
| Stopwatch sw = new Stopwatch(); | |
| sw.Start(); | |
| for (int i = 0; i < count; i++) | |
| { | |
| try | |
| { | |
| test.doTest(2, 0); | |
| } | |
| catch (Exception ex) | |
| { | |
| //string st = ex.StackTrace; | |
| } | |
| } | |
| sw.Stop(); | |
| long elapsedMilliseconds = sw.ElapsedMilliseconds; | |
| Console.WriteLine(String.Format("Total time for invocation: {0}", elapsedMilliseconds)); | |
| } | |
| public void doTest(int i, int level) | |
| { | |
| if (level < maxLevel) | |
| { | |
| try | |
| { | |
| doTest(i, ++level); | |
| } | |
| catch (Exception ex) | |
| { | |
| //string st = ex.StackTrace; | |
| throw new ApplicationException("level < maxLevel", ex); | |
| } | |
| } | |
| else | |
| { | |
| if (i > 1) | |
| throw new ApplicationException("level > maxLevel"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment