Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interleave: ICollection<> implementation #376

Merged
merged 3 commits into from
May 6, 2023

Conversation

viceroypenguin
Copy link
Owner

This PR adds an ICollection<> implementation of the Interleave operator.

Fixes #375

// * Summary *

BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1555/22H2/2022Update/SunValley2)
12th Gen Intel Core i7-12700H, 1 CPU, 20 logical and 14 physical cores
.NET SDK=8.0.100-preview.3.23178.7
  [Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
Method source N Mean Error StdDev Gen0 Gen1 Allocated
InterleaveCount Syste(...)t32]] [82] 4096 1.584 μs 0.0069 μs 0.0061 μs 0.0992 0.0019 1.22 KB
InterleaveCount Syst(...)32]] [154] 4096 43.721 μs 0.2876 μs 0.2691 μs 0.4272 0.0610 5.77 KB
InterleaveCopyTo Syste(...)t32]] [82] 4096 47.959 μs 0.3584 μs 0.3177 μs 1.7090 0.1221 20.98 KB
InterleaveCopyTo Syst(...)32]] [154] 4096 50.174 μs 0.2550 μs 0.2130 μs 3.1128 0.0610 38.20 KB
Code
#load "BenchmarkDotNet"

void Main()
{
	RunBenchmark();
}

public IEnumerable<object[]> EnumerableArguments()
{
	foreach (var i in new[] { 64, })
	{
		yield return new object[]
		{
			Enumerable.Range(1, i).Select(_ => Enumerable.Range(1, i).ToList().Select(SuperEnumerable.Identity)).ToList().Select(SuperEnumerable.Identity),
			i * i,
		};
		yield return new object[]
		{
			Enumerable.Range(1, i).Select(_ => Enumerable.Range(1, i).ToList()).ToList(),
			i * i,
		};
	}
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void InterleaveCount(IEnumerable<IEnumerable<int>> source, int N)
{
	_ = source.Interleave<int>().Count();
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void InterleaveCopyTo(IEnumerable<IEnumerable<int>> source, int N)
{
	_ = source.Interleave<int>().ToArray();
}

@viceroypenguin viceroypenguin added this to the 5.1.0 milestone May 6, 2023
@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (e762da8) 87.35% compared to head (543b5dc) 87.38%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
+ Coverage   87.35%   87.38%   +0.03%     
==========================================
  Files         239      239              
  Lines        7150     7160      +10     
  Branches     1664     1668       +4     
==========================================
+ Hits         6246     6257      +11     
+ Misses        464      463       -1     
  Partials      440      440              
Impacted Files Coverage Δ
Source/SuperLinq/FillBackward.cs 98.00% <ø> (ø)
Source/SuperLinq/FillForward.cs 100.00% <ø> (ø)
Source/SuperLinq/Interleave.cs 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@viceroypenguin viceroypenguin merged commit af4ca32 into master May 6, 2023
@viceroypenguin viceroypenguin deleted the interleave-icollection branch May 6, 2023 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICollection<T> version of Interleave
1 participant