Created
October 18, 2010 12:22
Revisions
-
ironfounderson revised this gist
Oct 18, 2010 . 1 changed file with 35 additions and 35 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,43 +1,43 @@ class EventTimeTest { public event EventHandler StandardEvent; public event EventHandler TrickyEvent = delegate { }; public void Test() { Stopwatch timer; EventArgs e = new EventArgs(); for (int testCase = 0; testCase < 9; testCase++) { int limit = (int)Math.Pow(10, testCase); timer = new Stopwatch(); timer.Start(); for (int iteration = 0; iteration < limit; iteration++) { OnStandardEvent(e); } timer.Stop(); double standardMs = timer.ElapsedMilliseconds; double standardTicks = timer.ElapsedTicks; timer = new Stopwatch(); timer.Start(); for (int iteration = 0; iteration < limit; iteration++) { OnTrickyEvent(e); } timer.Stop(); double msDifference = standardMs != 0 ? timer.ElapsedMilliseconds/standardMs : 0; double tickDifference = standardTicks != 0 ? timer.ElapsedTicks/standardTicks : 0; Console.WriteLine("{0}: MS Standard: {1} Tricky: {2} Difference {3}", limit, standardMs, timer.ElapsedMilliseconds, msDifference); Console.WriteLine("{0}: Ticks Standard: {1} Tricky: {2} Difference {3}", limit, standardTicks, timer.ElapsedTicks, tickDifference); } } private void OnStandardEvent(EventArgs e) { if (StandardEvent != null) StandardEvent(this, e); } private void OnTrickyEvent(EventArgs e) { TrickyEvent(this, e); } } -
ironfounderson revised this gist
Oct 18, 2010 . 1 changed file with 42 additions and 67 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,68 +1,43 @@ class EventTimeTest { public event EventHandler StandardEvent; public event EventHandler TrickyEvent = delegate { }; public void Test() { Stopwatch timer; EventArgs e = new EventArgs(); for (int testCase = 0; testCase < 9; testCase++) { int limit = (int)Math.Pow(10, testCase); timer = new Stopwatch(); timer.Start(); for (int iteration = 0; iteration < limit; iteration++) { OnStandardEvent(e); } timer.Stop(); double standardMs = timer.ElapsedMilliseconds; double standardTicks = timer.ElapsedTicks; timer = new Stopwatch(); timer.Start(); for (int iteration = 0; iteration < limit; iteration++) { OnTrickyEvent(e); } timer.Stop(); double msDifference = standardMs != 0 ? timer.ElapsedMilliseconds/standardMs : 0; double tickDifference = standardTicks != 0 ? timer.ElapsedTicks/standardTicks : 0; Console.WriteLine("{0}: MS Standard: {1} Tricky: {2} Difference {3}", limit, standardMs, timer.ElapsedMilliseconds, msDifference); Console.WriteLine("{0}: Ticks Standard: {1} Tricky: {2} Difference {3}", limit, standardTicks, timer.ElapsedTicks, tickDifference); } } private void OnStandardEvent(EventArgs e) { if (StandardEvent != null) StandardEvent(this, e); } private void OnTrickyEvent(EventArgs e) { TrickyEvent(this, e); } } -
ironfounderson created this gist
Oct 18, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ class EventTimeTest { public event EventHandler StandardEvent; public event EventHandler TrickyEvent = delegate { }; public void Test() { Stopwatch timer; EventArgs e = new EventArgs(); for (int testCase = 0; testCase < 9; testCase++) { int limit = (int)Math.Pow(10, testCase); timer = new Stopwatch(); timer.Start(); for (int iteration = 0; iteration < limit; iteration++) { OnStandardEvent(e); } timer.Stop(); double standardMs = timer.ElapsedMilliseconds; double standardTicks = timer.ElapsedTicks; timer = new Stopwatch(); timer.Start(); for (int iteration = 0; iteration < limit; iteration++) { OnTrickyEvent(e); } timer.Stop(); double msDifference = standardMs != 0 ? timer.ElapsedMilliseconds/standardMs : 0; double tickDifference = standardTicks != 0 ? timer.ElapsedTicks/standardTicks : 0; Console.WriteLine("{0}: MS Standard: {1} Tricky: {2} Difference {3}", limit, standardMs, timer.ElapsedMilliseconds, msDifference); Console.WriteLine("{0}: Ticks Standard: {1} Tricky: {2} Difference {3}", limit, standardTicks, timer.ElapsedTicks, tickDifference); } } private void OnStandardEvent(EventArgs e) { if (StandardEvent != null) StandardEvent(this, e); } private void OnTrickyEvent(EventArgs e) { TrickyEvent(this, e); } }