Skip to content

Latest commit

 

History

History
327 lines (233 loc) · 16 KB

File metadata and controls

327 lines (233 loc) · 16 KB

← .NET Matrix · Open the interactive matrix →

LINQ Queries

ZLinq leads the current rating · 6 libraries · 18 scenarios

Rating

In every scenario the fastest library scores 100 points and the one allocating least scores 100 more; four times slower is half the points, and an unsupported scenario is worth nothing. Time and memory reach 1700 each here, so the maximum is 3400. See workflows/rating.md.

LINQ Queries rating

# Library Scenarios Time Memory Points Group wins
1 ZLinq 17/17 1589 1697 3286 gold in Advanced, gold in Core, gold in Partitioning, gold in Sequences, gold in Sources
2 System.Linq 16/17 1443 1373 2815 silver in Advanced, silver in Core, silver in Partitioning, silver in Sequences, bronze in Sources
3 StructLinq 14/17 931 1229 2160 bronze in Sequences
4 LinqAF 16/17 1082 1072 2154 bronze in Advanced, bronze in Partitioning
5 NetFabric.Hyperlinq 12/17 944 900 1845 silver in Sources, bronze in Core
How the points were earned — every scenario, with the measurements behind it

Each row is one scenario. Best is the lowest result among the rated libraries that completed it, and the points follow from the two figures beside them: 100 × √((best + step) / (result + step)), with a step of 1 ns for time and 24 B for memory. A dash means the library did not complete the scenario, and it scores nothing for it. Add the two Points columns over every scenario and you get the rating above. The same breakdown appears as a hint on any points value in the application.

1. ZLinq — 3286 of 3400

Scenario Time Best Points Memory Best Points
Filter and Count 9.84 μs 9.01 μs 95.7 0 B 0 B 100
Project To Array 4.9 μs 4.9 μs 100 39.09 KB 39.09 KB 100
Filter, Project, Materialize 8.24 μs 6.65 μs 89.8 9.83 KB 9.83 KB 100
Chained Pipeline 12.62 μs 9.34 μs 86 3.93 KB 3.93 KB 100
List Source 17.62 μs 12.6 μs 84.6 13.07 KB 13.07 KB 100
Opaque Source 32.1 μs 26.92 μs 91.6 13.1 KB 13.1 KB 100
Span Source 13.95 μs 13.95 μs 100 13.07 KB 13.07 KB 100
Paged Slice 381.65 ns 381.65 ns 100 3.93 KB 3.93 KB 100
Any Match 3.14 μs 3.14 μs 100 0 B 0 B 100
First Match 2.27 μs 2.27 μs 100 0 B 0 B 100
Flatten Nested Sequences 27.74 μs 7.11 μs 50.6 39.09 KB 39.09 KB 100
Distinct Values 40.87 μs 33.58 μs 90.6 3.98 KB 3.98 KB 100
Zip Pairs 13.81 μs 13.81 μs 100 39.09 KB 39.09 KB 100
Aggregate 3.48 μs 3.48 μs 99.9 0 B 0 B 100
Ordered Top N 41.98 μs 41.98 μs 100 264 B 248 B 97.2
Group and Aggregate 102.93 μs 102.93 μs 100 130.59 KB 130.59 KB 100
Join and Project 78.81 μs 78.81 μs 100 129.19 KB 129.19 KB 100

2. System.Linq — 2815 of 3400

Scenario Time Best Points Memory Best Points
Filter and Count 9.01 μs 9.01 μs 100 48 B 0 B 57.7
Project To Array 5.82 μs 4.9 μs 91.8 39.13 KB 39.09 KB 99.9
Filter, Project, Materialize 6.65 μs 6.65 μs 100 9.93 KB 9.83 KB 99.5
Chained Pipeline 15.18 μs 9.34 μs 78.5 4.14 KB 3.93 KB 97.4
List Source 12.6 μs 12.6 μs 100 13.22 KB 13.07 KB 99.4
Opaque Source 27.16 μs 26.92 μs 99.6 13.22 KB 13.1 KB 99.6
Span Source — 13.95 μs 0 — 13.07 KB 0
Paged Slice 381.86 ns 381.65 ns 100 4.02 KB 3.93 KB 98.8
Any Match 3.16 μs 3.14 μs 99.8 0 B 0 B 100
First Match 2.35 μs 2.27 μs 98.3 0 B 0 B 100
Flatten Nested Sequences 7.11 μs 7.11 μs 100 39.18 KB 39.09 KB 99.9
Distinct Values 86.8 μs 33.58 μs 62.2 179.3 KB 3.98 KB 14.9
Zip Pairs 80.91 μs 13.81 μs 41.3 39.24 KB 39.09 KB 99.8
Aggregate 3.49 μs 3.48 μs 99.9 0 B 0 B 100
Ordered Top N 42.4 μs 41.98 μs 99.5 78.56 KB 248 B 5.814
Group and Aggregate 111.92 μs 102.93 μs 95.9 131.27 KB 130.59 KB 99.7
Join and Project 135.42 μs 78.81 μs 76.3 129.45 KB 129.19 KB 99.9

3. StructLinq — 2160 of 3400

Scenario Time Best Points Memory Best Points
Filter and Count 12.62 μs 9.01 μs 84.5 64 B 0 B 52.2
Project To Array 10.76 μs 4.9 μs 67.5 39.09 KB 39.09 KB 100
Filter, Project, Materialize 34 μs 6.65 μs 44.2 9.9 KB 9.83 KB 99.6
Chained Pipeline 11.68 μs 9.34 μs 89.4 4.06 KB 3.93 KB 98.4
List Source 22.14 μs 12.6 μs 75.4 13.14 KB 13.07 KB 99.7
Opaque Source 35.26 μs 26.92 μs 87.4 13.16 KB 13.1 KB 99.8
Span Source — 13.95 μs 0 — 13.07 KB 0
Paged Slice 845.43 ns 381.65 ns 67.2 3.99 KB 3.93 KB 99.2
Any Match 8.69 μs 3.14 μs 60.2 32 B 0 B 65.5
First Match 5.2 μs 2.27 μs 66.1 32 B 0 B 65.5
Flatten Nested Sequences 64.08 μs 7.11 μs 33.3 54.77 KB 39.09 KB 84.5
Distinct Values 33.58 μs 33.58 μs 100 4.01 KB 3.98 KB 99.7
Zip Pairs 48.78 μs 13.81 μs 53.2 39.19 KB 39.09 KB 99.9
Aggregate 6.4 μs 3.48 μs 73.7 32 B 0 B 65.5
Ordered Top N 517.72 μs 41.98 μs 28.5 248 B 248 B 100
Group and Aggregate — 102.93 μs 0 — 130.59 KB 0
Join and Project — 78.81 μs 0 — 129.19 KB 0

4. LinqAF — 2154 of 3400

Scenario Time Best Points Memory Best Points
Filter and Count 10.44 μs 9.01 μs 92.9 0 B 0 B 100
Project To Array 30.82 μs 4.9 μs 39.9 151.38 KB 39.09 KB 50.8
Filter, Project, Materialize 9.6 μs 6.65 μs 83.3 32.27 KB 9.83 KB 55.2
Chained Pipeline 9.34 μs 9.34 μs 100 3.93 KB 3.93 KB 100
List Source 28.34 μs 12.6 μs 66.7 45.31 KB 13.07 KB 53.7
Opaque Source 44.33 μs 26.92 μs 77.9 45.34 KB 13.1 KB 53.8
Span Source — 13.95 μs 0 — 13.07 KB 0
Paged Slice 2.68 μs 381.65 ns 37.8 3.93 KB 3.93 KB 100
Any Match 3.17 μs 3.14 μs 99.6 0 B 0 B 100
First Match 2.38 μs 2.27 μs 97.8 0 B 0 B 100
Flatten Nested Sequences 82.98 μs 7.11 μs 29.3 151.38 KB 39.09 KB 50.8
Distinct Values 258.24 μs 33.58 μs 36.1 246.72 KB 3.98 KB 12.7
Zip Pairs 34.77 μs 13.81 μs 63 151.38 KB 39.09 KB 50.8
Aggregate 3.48 μs 3.48 μs 100 0 B 0 B 100
Ordered Top N 316.26 μs 41.98 μs 36.4 257.14 KB 248 B 3.214
Group and Aggregate 242.74 μs 102.93 μs 65.1 194.73 KB 130.59 KB 81.9
Join and Project 248.14 μs 78.81 μs 56.4 374.56 KB 129.19 KB 58.7

5. NetFabric.Hyperlinq — 1845 of 3400

Scenario Time Best Points Memory Best Points
Filter and Count 12.51 μs 9.01 μs 84.9 0 B 0 B 100
Project To Array 10.37 μs 4.9 μs 68.8 39.09 KB 39.09 KB 100
Filter, Project, Materialize 11.8 μs 6.65 μs 75.1 32.27 KB 9.83 KB 55.2
Chained Pipeline 11.18 μs 9.34 μs 91.4 8.3 KB 3.93 KB 68.9
List Source 19.49 μs 12.6 μs 80.4 29.48 KB 13.07 KB 66.6
Opaque Source 26.92 μs 26.92 μs 100 29.52 KB 13.1 KB 66.7
Span Source 15.2 μs 13.95 μs 95.8 29.48 KB 13.07 KB 66.6
Paged Slice 971.32 ns 381.65 ns 62.7 3.93 KB 3.93 KB 100
Any Match 6.03 μs 3.14 μs 72.2 0 B 0 B 100
First Match 2.36 μs 2.27 μs 98.1 0 B 0 B 100
Flatten Nested Sequences 38.97 μs 7.11 μs 42.7 103.7 KB 39.09 KB 61.4
Distinct Values 64.4 μs 33.58 μs 72.2 179.21 KB 3.98 KB 15
Zip Pairs — 13.81 μs 0 — 39.09 KB 0
Aggregate — 3.48 μs 0 — 0 B 0
Ordered Top N — 41.98 μs 0 — 248 B 0
Group and Aggregate — 102.93 μs 0 — 130.59 KB 0
Join and Project — 78.81 μs 0 — 129.19 KB 0

Benchmark overview

Core

LINQ Queries Core benchmark overview

More overview charts (4)

Sources

LINQ Queries Sources benchmark overview

Partitioning

LINQ Queries Partitioning benchmark overview

Sequences

LINQ Queries Sequences benchmark overview

Advanced

LINQ Queries Advanced benchmark overview

Compared libraries (6)

Hand-coded logo Hand-coded
Direct loops written in C# without any query library.
Compare →
LinqAF logo LinqAF 3.0.0
A low-allocation re-implementation of LINQ-to-Objects that shadows the System.Linq operators and returns struct enumerables. Last released in 2019.
Compare →
NetFabric.Hyperlinq logo NetFabric.Hyperlinq 3.0.0-beta9
A value-enumerable LINQ implementation with span sources and low-allocation pipelines. The compared version is a prerelease.
Compare →
StructLinq logo StructLinq 0.28.2
A struct-based LINQ implementation with optional struct predicates that avoid delegate indirection. Last released in 2022.
Compare →
System.Linq logo System.Linq
The LINQ-to-Objects implementation included with .NET, exposing the Enumerable operators over IEnumerable sequences.
Compare →
ZLinq logo ZLinq 1.5.6
A zero-allocation LINQ implementation built on struct enumerators, with span and SIMD support and a complete operator surface.
Compare →

Benchmark scenarios (18)

01 · Filter and Count

Filters 10,000 integers with a predicate and counts the survivors.

LINQ Queries Filter and Count benchmark

02 · Project To Array

Projects 10,000 integers through a selector and materializes a new array.

LINQ Queries Project To Array benchmark

03 · Filter, Project, Materialize

Filters 5,000 orders by amount, projects one property, and materializes a list.

LINQ Queries Filter, Project, Materialize benchmark

04 · Chained Pipeline

Composes a filter, a projection, a second filter, and a limit into one four-stage query.

LINQ Queries Chained Pipeline benchmark

05 · List Source

Runs the canonical filter and projection over a List<int>.

LINQ Queries List Source benchmark

06 · Opaque Source

Runs the same query over an IEnumerable<int> exposing no count, indexer, or array.

LINQ Queries Opaque Source benchmark

07 · Span Source

Runs the same query over a ReadOnlySpan<int>.

LINQ Queries Span Source benchmark

08 · Paged Slice

Skips 4,000 integers, takes the next 1,000, and materializes them.

LINQ Queries Paged Slice benchmark

09 · Any Match

Reports whether any of 10,000 integers satisfies a predicate first met at index 9,500.

LINQ Queries Any Match benchmark

10 · First Match

Returns the first of 5,000 orders satisfying a predicate first met at index 4,500.

LINQ Queries First Match benchmark

11 · Flatten Nested Sequences

Flattens 500 inner arrays of 20 integers and materializes the result.

LINQ Queries Flatten Nested Sequences benchmark

12 · Distinct Values

Reduces 10,000 integers containing 1,000 distinct values to the distinct set.

LINQ Queries Distinct Values benchmark

13 · Zip Pairs

Pairs two sequences of 10,000 integers and materializes the products.

LINQ Queries Zip Pairs benchmark

14 · Aggregate

Folds 10,000 integers with a caller-supplied accumulator and a seed.

LINQ Queries Aggregate benchmark

15 · Ordered Top N

Orders 5,000 orders by descending amount and materializes the identifiers of the top 20.

LINQ Queries Ordered Top N benchmark

16 · Group and Aggregate

Groups 5,000 orders by region and produces one summed total per region.

LINQ Queries Group and Aggregate benchmark

17 · Join and Project

Joins 5,000 orders to 500 customers on the customer key and projects the pairs.

LINQ Queries Join and Project benchmark

18 · Struct Predicate Filter

Filters and counts 10,000 integers with a struct-typed predicate instead of a delegate.

Not rated: With this few rated entrants, the reference is a library's own result, not a result earned against a competitor, so the full 200 points would not reflect a win. (1 of 5 rated libraries support this.)

LINQ Queries Struct Predicate Filter benchmark