* Run code cleanup * Dotnet format benchmarks project * Fix up Test.Common * Run dotnet format + manual cleanup * Run code cleanup for unit tests * Run dotnet format * Fix up errors * Manual cleanup of Unit test project * Update tests/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/TestDbMeta.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Benchmarks/TypeFinderBenchmarks.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update tests/Umbraco.Tests.Integration/Umbraco.Core/Events/EventAggregatorTests.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Fix according to review * Fix after merge * Fix errors Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Zeegaan <nge@umbraco.dk>
34 lines
632 B
C#
34 lines
632 B
C#
using System.Collections.Generic;
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
namespace Umbraco.Tests.Benchmarks;
|
|
|
|
[MemoryDiagnoser]
|
|
public class EnumeratorBenchmarks
|
|
{
|
|
[Benchmark(Baseline = true)]
|
|
public void WithArray()
|
|
{
|
|
foreach (var t in EnumerateOneWithArray(1))
|
|
{
|
|
;
|
|
}
|
|
}
|
|
|
|
[Benchmark]
|
|
public void WithYield()
|
|
{
|
|
foreach (var t in EnumerateOneWithYield(1))
|
|
{
|
|
;
|
|
}
|
|
}
|
|
|
|
private IEnumerable<T> EnumerateOneWithArray<T>(T o) => new[] { o };
|
|
|
|
private IEnumerable<T> EnumerateOneWithYield<T>(T o)
|
|
{
|
|
yield return o;
|
|
}
|
|
}
|