public void EnumerateNone([Values(0, 1, 2, 3, 100 /*, 200_000_000*/)] int count) { var collection = new StubCollection(count); AssertToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).ToArray(), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).ToArray(), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).ToArray(), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0), count, 0); AssertIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0).Where(i => i != 0), count, 0); }
public void BreakEarly([Values(0, 1, 2, 3, 100 /*, 200_000_000*/)] int count, [Values(0, 1, 5)] int breakAfter) { var collection = new StubCollection(count); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinq().Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinq().Take(breakAfter), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Take(breakAfter), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakToArrayBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter).ToArray(), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinq().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); AssertEarlyBreakIEnumerableBehaviour(() => collection.AsLowCostLinqWithoutChecks().Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Where(i => i == 0).Take(breakAfter), count, breakAfter); }