Skip to content

Commit

Permalink
changed benchmarks to include cached count
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 12, 2012
1 parent cf62998 commit 47075ad
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/ServiceStack.Text.Tests/Support/BenchmarkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public void Test_for_list_enumeration()
{
List<Cat> list = 20.Times(x => new Cat { Name = "Cat" });
var results = 0;
var listLength = list.Count;

CompareMultipleRuns(
"With foreach",
Expand All @@ -184,7 +185,7 @@ public void Test_for_list_enumeration()
},
"With for",
() => {
for (var i = 0; i < list.Count; i++)
for (var i = 0; i < listLength; i++)
{
var cat = list[i];
results++;
Expand All @@ -199,7 +200,7 @@ public void Test_for_Ilist_enumeration()
{
IList<Cat> list = 20.Times(x => new Cat { Name = "Cat" });
var results = 0;

var listLength = list.Count;
CompareMultipleRuns(
"With foreach",
() => {
Expand All @@ -210,7 +211,7 @@ public void Test_for_Ilist_enumeration()
},
"With for",
() => {
for (var i = 0; i < list.Count; i++)
for (var i = 0; i < listLength; i++)
{
var cat = list[i];
results++;
Expand All @@ -220,11 +221,6 @@ public void Test_for_Ilist_enumeration()
Console.WriteLine(results);
}

[Test]
public void A()
{

}

}
}

0 comments on commit 47075ad

Please sign in to comment.