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

Window: IList<> implementation #427

Merged
merged 4 commits into from
May 17, 2023
Merged

Window: IList<> implementation #427

merged 4 commits into from
May 17, 2023

Conversation

viceroypenguin
Copy link
Owner

This PR adds an IList<> implementation of the Window operator.

Fixes #419

// * Summary *

BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1702/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 source1 N Mean Error StdDev Gen0 Gen1 Allocated
WindowCount Syste(...)nt32] [47] 10000 9.149 ns 0.0447 ns 0.0418 ns 0.0025 0.0000 32 B
WindowCount Syste(...)nt32] [62] 10000 190,218.615 ns 1,082.6772 ns 904.0845 ns 82.5195 0.2441 1038192 B
WindowCopyTo Syste(...)nt32] [47] 10000 218,147.174 ns 1,371.7392 ns 1,145.4644 ns 88.8672 48.8281 1117984 B
WindowCopyTo Syste(...)nt32] [62] 10000 287,875.178 ns 3,067.1661 ns 2,718.9628 ns 99.1211 58.1055 1249777 B
WindowElementAt Syste(...)nt32] [47] 10000 45.165 ns 0.4497 ns 0.3986 ns 0.0108 0.0001 136 B
WindowElementAt Syste(...)nt32] [62] 10000 153,205.796 ns 1,012.1909 ns 946.8040 ns 66.1621 0.2441 832376 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).Where(_ => true),
			i,
		};
		yield return new object[]
		{
			Enumerable.Range(1, i).ToList(),
			i,
		};
	}
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void WindowCount(IEnumerable<int> source1, int N)
{
	_ = source1.Window(20).Count();
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void WindowCopyTo(IEnumerable<int> source1, int N)
{
	_ = source1.Window(20).ToArray();
}

[Benchmark]
[ArgumentsSource(nameof(EnumerableArguments))]
public void WindowElementAt(IEnumerable<int> source1, int N)
{
	_ = source1.Window(20).ElementAt(8_000);
}

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

codecov bot commented May 17, 2023

Codecov Report

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

Comparison is base (08e8016) 87.99% compared to head (0b7bcc9) 88.04%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #427      +/-   ##
==========================================
+ Coverage   87.99%   88.04%   +0.04%     
==========================================
  Files         242      242              
  Lines        7498     7526      +28     
  Branches     1725     1730       +5     
==========================================
+ Hits         6598     6626      +28     
  Misses        462      462              
  Partials      438      438              
Impacted Files Coverage Δ
Source/SuperLinq/Window.cs 100.00% <100.00%> (ø)

☔ 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 9e71e45 into master May 17, 2023
@viceroypenguin viceroypenguin deleted the window-ilist branch May 17, 2023 01:42
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.

IList<> version of Window
1 participant