forked from NetFabric/LinqBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRangeToArray.cs
More file actions
60 lines (52 loc) · 1.47 KB
/
RangeToArray.cs
File metadata and controls
60 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using BenchmarkDotNet.Attributes;
using JM.LinqFaster.SIMD;
using com.tinyield;
using NetFabric.Hyperlinq;
using StructLinq;
using System.Buffers;
using System.Linq;
namespace LinqBenchmarks.Range
{
public partial class RangeToArray: RangeBenchmarkBase
{
[Benchmark(Baseline = true)]
public int[] ForLoop()
{
var array = new int[Count];
for (var index = 0; index < Count; index++)
array[index] = index + Start;
return array;
}
[Benchmark]
public int[] Linq()
=> System.Linq.Enumerable
.Range(Start, Count).ToArray();
[Benchmark]
public int[] LinqFaster()
=> JM.LinqFaster.LinqFaster
.RangeArrayF(Start, Count);
[Benchmark]
public int[] LinqFaster_SIMD()
=> LinqFasterSIMD
.RangeS(Start, Count);
[Benchmark]
public int[] LinqAF()
=> global::LinqAF.Enumerable
.Range(Start, Count)
.ToArray();
[Benchmark]
public int[] StructLinq()
=> StructEnumerable
.Range(Start, Count)
.ToArray(x => x);
[Benchmark]
public int[] Hyperlinq()
=> ValueEnumerable
.Range(Start, Count)
.ToArray();
[Benchmark]
public int[] Tinyield() => Query.Range(Start, Count)
.ToArray();
}
}