< Summary - ReFlex - Library

Information
Class: PointCloud.Benchmark.Benchmarks.IteratePointCloud.IterationMethods
Assembly: ReFlex.PointCloud.Benchmark
File(s): D:\a\reflex\reflex\test\Library\Performance\PointCloud.Benchmark\Benchmarks\IteratePointCloud\IterationMethods.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 53
Coverable lines: 53
Total lines: 90
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 14
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
Iterate1dIndex()0%620%
Iterate2dIndex()0%2040%
IterateArray()0%620%
IterateJaggedArray()0%2040%
IterateSpan()0%620%

File(s)

D:\a\reflex\reflex\test\Library\Performance\PointCloud.Benchmark\Benchmarks\IteratePointCloud\IterationMethods.cs

#LineLine coverage
 1using BenchmarkDotNet.Attributes;
 2using PointCloud.Benchmark.Common;
 3using PointCloud.Benchmark.Util;
 4
 5namespace PointCloud.Benchmark.Benchmarks.IteratePointCloud;
 6
 7[MemoryDiagnoser]
 8public class IterationMethods
 9{
 10    private int _width;
 11    private int _height;
 12
 13    private readonly PointCloud3 _pCloud3;
 14
 015    public IterationMethods()
 016    {
 017        var data = DataLoader.Load();
 018        _width = data.Item1;
 019        _height = data.Item2;
 20
 21
 022        _pCloud3 = new PointCloud3(_width, _height);
 023        _pCloud3.Update(data.Item3);
 024    }
 25
 26    [Benchmark]
 27    public float Iterate1dIndex()
 028    {
 029        var value = 0f;
 030        for (var i = 0; i < _pCloud3.Size; i++)
 031        {
 032            value = _pCloud3[i].Z;
 033        }
 34
 035        return value;
 036    }
 37
 38    [Benchmark]
 39    public float Iterate2dIndex()
 040    {
 041        var value = 0f;
 042        for (var x = 0; x < _pCloud3.SizeX; x++)
 043        {
 044            for(var y = 0; y < _pCloud3.SizeY; y++)
 045                value = _pCloud3[x,y].Z;
 046        }
 47
 048        return value;
 049    }
 50
 51    [Benchmark]
 52    public float IterateArray()
 053    {
 054        var value = 0f;
 055        var array = _pCloud3.AsArray();
 056        for (var i = 0; i < _pCloud3.Size; i++)
 057        {
 058            value = array[i].Z;
 059        }
 60
 061        return value;
 062    }
 63
 64    [Benchmark]
 65    public float IterateJaggedArray()
 066    {
 067        var value = 0f;
 068        var array = _pCloud3.AsJaggedArray();
 069        for (var x = 0; x < _pCloud3.SizeX; x++)
 070        {
 071            for(var y = 0; y < _pCloud3.SizeY; y++)
 072                value = array[x][y].Z;
 073        }
 74
 075        return value;
 076    }
 77
 78    [Benchmark]
 79    public float IterateSpan()
 080    {
 081        var value = 0f;
 082        var span = _pCloud3.AsArray().AsSpan();
 083        for (var i = 0; i < _pCloud3.SizeX; i++)
 084        {
 085            value = span[i].Z;
 086        }
 87
 088        return value;
 089    }
 90}