Since I do a fair bit of per­for­mance tests on ran­dom things that pique my inter­est, it’s only nat­ur­al that I should make the task of car­ry­ing out these tests eas­i­er for myself, so over the week­end I put togeth­er a sim­ple, no frills frame­work to do just that!

The Sim­ple­SpeedTester project is intend­ed to make it eas­i­er to:

  • time the exe­cu­tion of some code
  • orches­trate mul­ti­ple runs of the same test
  • col­late the exe­cu­tion time of the test runs
  • pro­vide an easy way to obtain sum­ma­ry for the tests

What it’s not

It’s not a pro­fil­er! It doesn’t tell you which line of your code is tak­ing what per­cent­age of your CPU time or how much mem­o­ry is used where. It’s intend­ed for one thing and one thing only – help you speed test a spe­cif­ic piece of code/method over mul­ti­ple runs, col­late the results and work out the aver­age for you so you don’t have to.

Getting Started

To get start­ed, down­load the bina­ries here, ref­er­ence the SimpleSpeedTester.dll in your project, and all you need is one line of code to sched­ule a test to be run mul­ti­ple times and get a sum­ma­ry of the test runs:

   1: // initialize a new test group

   2: var testGroup = new TestGroup("Example2");


   4: // PlanAndExecute executes the Action delegate 5 times and returns the result summary

   5: var testResultSummary = testGroup.PlanAndExecute("Test1", () => { }, 5);


   7: Console.WriteLine(testResultSummary);

   8: /* prints out something along the line of

   9:  *

  10:  * Test Group [Example2], Test [Test1] results summary:

  11:  * Successes   [5]

  12:  * Failures    [0] 

  13:  * Average Exec Time [...] milliseconds

  14:  *

  15:  */

And you’re done! Easy, right? ;-)

I’ve includ­ed a cou­ple more exam­ples here cov­er­ing the most com­mon use cas­es, more will be added as I add more func­tion­al­i­ties.

So what are you wait­ing for? Go on, down­load it and play around with it, let me know what you think, any con­struc­tive sug­ges­tions are very wel­comed!