AutoFixture/AutoFixture — pull request #218 by adamchester (2013-12-07 00:17:23+00:00)
Title: Improve performance

I ran some performance benchmarks. I noticed some 'hot paths', and I improved them (performance-wise).

However, I'm not sure each individual change is worthwhile. Personally, I find the changes to be ugly (I prefer the readability of the current LINQ implementations).

## Test
In both `BEFORE` and `AFTER` results, I added the following test (which simply creates a specimen in a tight loop):
```csharp
class ASpecimenWithTheLot
{
public string String1 { get; set; }
public int? Int1 { get; set; }
public bool? Bool1 { get; set; }
public DateTime? DateTime1 { get; set; }
public Guid? Guid1 { get; set; }
public ChildFields Child1 { get; set; }
public IEnumerable Children { get; set; }
public ChildFields[] ChildrenArray { get; set; }
public Dictionary ChildrenDictionary { get; set; }
public class ChildFields
{
public string ChildString;
public object ChildObject;
public DateTime? ChildDateTime;
}
}
```

And the test itself:
```csharp
var sw = new Stopwatch();
sw.Start();
for (int requestNumber = 0; requestNumber < 1000; requestNumber++)
{
var value = sut.Create();
}
sw.Stop();
Console.WriteLine("CreateSpecimensQuickly, elapsed: " + sw.Elapsed);
```

## Results
```
BEFORE:
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 11.316 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 10.653 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 10.292 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 10.458 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 11.219 seconds
CreateSpecimensQuickly, elapsed: 00:00:02.8651137
CreateSpecimensQuickly, elapsed: 00:00:03.6820665
CreateSpecimensQuickly, elapsed: 00:00:03.8420800
CreateSpecimensQuickly, elapsed: 00:00:02.8832626
CreateSpecimensQuickly, elapsed: 00:00:03.1097470

AFTER:
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 9.419 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 9.429 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 9.573 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 9.724 seconds
TOTAL Tests: 4217, Failures: 0, Skipped: 0, Time: 9.862 seconds
CreateSpecimensQuickly, elapsed: 00:00:02.0022394
CreateSpecimensQuickly, elapsed: 00:00:02.2535522
CreateSpecimensQuickly, elapsed: 00:00:03.0139508
CreateSpecimensQuickly, elapsed: 00:00:02.1202750
CreateSpecimensQuickly, elapsed: 00:00:02.0602971
```

Note that each line above was collected by copying from the build.txt, from a totally separate run of the following command:
```
msbuild BuildRelease.msbuild /t:test /m:8 > build.txt
```

And here is a nice graph:

![image](https://f.cloud.github.com/assets/570470/1697173/c2fbcd38-5ed4-11e3-8361-5bf7f1f409a9.png)