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

FallBackward: ICollection<> implementation #371

Merged
merged 9 commits into from
May 5, 2023

Conversation

viceroypenguin
Copy link
Owner

@viceroypenguin viceroypenguin commented May 4, 2023

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

Fixes #370

// * 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
FillBackwardCount Syste(...)nt32] [47] 10000 13.57 ns 0.169 ns 0.150 ns 0.0032 0.0000 40 B
FillBackwardCount Syste(...)rator [36] 10000 80,539.61 ns 569.023 ns 532.265 ns - - 376 B
FillBackwardCopyTo Syste(...)nt32] [47] 10000 20,054.10 ns 173.320 ns 153.643 ns 3.1738 0.0305 40064 B
FillBackwardCopyTo Syste(...)rator [36] 10000 95,658.32 ns 497.560 ns 465.418 ns 3.1738 0.1221 40400 B
Code
#load "BenchmarkDotNet"

void Main()
{
	RunBenchmark();
}

public IEnumerable<object[]> EnumerableArguments()
{
	foreach (var i in new[] { 10_000, })
	{
		yield return new object[] { Enumerable.Range(1, i), i, };
		yield return new object[] { Enumerable.Range(1, i).ToList(), i, };
	}
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void FillBackwardCount(IEnumerable<int> source, int N)
{
	_ = source.FillBackward(e => e % 10 != 5).Count();
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void FillBackwardCopyTo(IEnumerable<int> source, int N)
{
	var arr = new int[N];
	_ = source.FillBackward(e => e % 10 != 5).CopyTo(arr);
}

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

codecov bot commented May 4, 2023

Codecov Report

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

Comparison is base (b5de5aa) 87.26% compared to head (bcb7617) 87.32%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
+ Coverage   87.26%   87.32%   +0.05%     
==========================================
  Files         239      239              
  Lines        7098     7123      +25     
  Branches     1650     1657       +7     
==========================================
+ Hits         6194     6220      +26     
+ Misses        464      463       -1     
  Partials      440      440              
Impacted Files Coverage Δ
Source/SuperLinq/FillBackward.cs 98.00% <100.00%> (+2.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 44845c8 into master May 5, 2023
@viceroypenguin viceroypenguin deleted the fallback-collection branch May 5, 2023 02:53
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 FillBackward
1 participant