Skip to content

Instantly share code, notes, and snippets.

@sinairv
Created August 4, 2015 02:15
Show Gist options
  • Save sinairv/a4ece3453deb709fcacc to your computer and use it in GitHub Desktop.
Save sinairv/a4ece3453deb709fcacc to your computer and use it in GitHub Desktop.
Performance Measurement
const int WarmUpCount = 3;
const int TestCount = 100;
var stopWatch = new Stopwatch();
stopWatch.Reset();
for (int i = 0; i < WarmUpCount + TestCount; i++)
{
if(i >= WarmUpCount)
stopWatch.Start();
var someVariable = FunctionCallToMeasure();
if(i >= WarmUpCount)
stopWatch.Stop();
}
var elapsed = stopWatch.ElapsedMilliseconds;
var averageRunTime = (decimal)elapsed/TestCount;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment