Skip to content

Commit 6a7e3e3

Browse files
committed
Use Length - 1
1 parent 9bb2afa commit 6a7e3e3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Benchmarks/ArrayIterationBenchmarks.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ BenchmarkDotNet=v0.13.0.1555-nightly, OS=Windows 10.0.19043.1081 (21H1/May2021Up
1818
Intel Core i7-7567U CPU 3.50GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores
1919
.NET SDK=6.0.100-preview.5.21302.13
2020
[Host] : .NET 6.0.0 (6.0.21.30105), X64 RyuJIT
21-
Job-XVAVUK : .NET 6.0.0 (6.0.21.30105), X64 RyuJIT
21+
Job-IRYCMS : .NET 6.0.0 (6.0.21.30105), X64 RyuJIT
2222

2323
Runtime=.NET 6.0
2424

2525
```
26-
| Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
27-
|--------------------- |-------- |-----------:|--------:|--------:|-------------:|--------:|------:|------:|------:|----------:|
28-
| Foreach | 1000000 | 412.6 μs | 2.14 μs | 1.67 μs | baseline | | - | - | - | - |
29-
| For | 1000000 | 429.4 μs | 2.29 μs | 2.03 μs | 1.04x slower | 0.01x | - | - | - | - |
30-
| For_Unsafe | 1000000 | 413.0 μs | 3.60 μs | 2.81 μs | 1.00x slower | 0.01x | - | - | - | - |
31-
| ForAdamczewski | 1000000 | 408.5 μs | 2.42 μs | 2.14 μs | 1.01x faster | 0.01x | - | - | - | - |
32-
| ForAdamczewskiUnsafe | 1000000 | 352.8 μs | 1.71 μs | 1.52 μs | 1.17x faster | 0.01x | - | - | - | - |
33-
| Span | 1000000 | 413.7 μs | 3.02 μs | 2.82 μs | 1.00x slower | 0.01x | - | - | - | - |
34-
| ArraySegment_Foreach | 1000000 | 2,796.4 μs | 7.48 μs | 7.00 μs | 6.78x slower | 0.04x | - | - | - | 1 B |
35-
| ArraySegment_For | 1000000 | 805.3 μs | 4.55 μs | 3.55 μs | 1.95x slower | 0.01x | - | - | - | - |
36-
| ArraySegment_AsSpan | 1000000 | 412.9 μs | 2.45 μs | 2.29 μs | 1.00x slower | 0.01x | - | - | - | - |
37-
| ArraySegment_AsArray | 1000000 | 802.6 μs | 4.70 μs | 4.17 μs | 1.94x slower | 0.01x | - | - | - | - |
26+
| Method | Count | Mean | Error | StdDev | Ratio | RatioSD | Gen 0 | Gen 1 | Gen 2 | Allocated |
27+
|--------------------- |-------- |-----------:|---------:|--------:|-------------:|--------:|------:|------:|------:|----------:|
28+
| Foreach | 1000000 | 424.2 μs | 5.91 μs | 5.53 μs | baseline | | - | - | - | - |
29+
| For | 1000000 | 428.7 μs | 2.69 μs | 2.52 μs | 1.01x slower | 0.01x | - | - | - | - |
30+
| For_Unsafe | 1000000 | 412.9 μs | 3.31 μs | 2.76 μs | 1.03x faster | 0.01x | - | - | - | - |
31+
| ForAdamczewski | 1000000 | 404.1 μs | 2.42 μs | 2.26 μs | 1.05x faster | 0.02x | - | - | - | - |
32+
| ForAdamczewskiUnsafe | 1000000 | 355.1 μs | 3.48 μs | 3.25 μs | 1.19x faster | 0.02x | - | - | - | - |
33+
| Span | 1000000 | 411.8 μs | 2.92 μs | 2.28 μs | 1.03x faster | 0.01x | - | - | - | - |
34+
| ArraySegment_Foreach | 1000000 | 2,800.7 μs | 10.24 μs | 9.08 μs | 6.60x slower | 0.09x | - | - | - | 1 B |
35+
| ArraySegment_For | 1000000 | 805.2 μs | 4.48 μs | 4.19 μs | 1.90x slower | 0.02x | - | - | - | - |
36+
| ArraySegment_AsSpan | 1000000 | 412.4 μs | 2.08 μs | 1.74 μs | 1.03x faster | 0.01x | - | - | - | - |
37+
| ArraySegment_AsArray | 1000000 | 798.7 μs | 4.39 μs | 3.67 μs | 1.88x slower | 0.03x | - | - | - | - |

NetFabric.Hyperlinq.Benchmarks/Benchmarks/ArrayIterationBenchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public unsafe int For_Unsafe()
5454
var sum = 0;
5555
fixed (int* source = array)
5656
{
57-
for (var index = 0; index < len; index++)
57+
for (var index = 0; index <= len; index++)
5858
{
5959
var item = source[index];
6060
sum += item;

0 commit comments

Comments
 (0)