| | | 1 | | using BenchmarkDotNet.Attributes; |
| | | 2 | | using PointCloud.Benchmark.Util; |
| | | 3 | | using ReFlex.Core.Common.Components; |
| | | 4 | | |
| | | 5 | | namespace PointCloud.Benchmark.Benchmarks.UpdatePointCloud; |
| | | 6 | | |
| | | 7 | | [MemoryDiagnoser] |
| | | 8 | | public class UpdateMethods |
| | | 9 | | { |
| | | 10 | | private int _width; |
| | | 11 | | private int _height; |
| | | 12 | | |
| | | 13 | | private readonly Common.PointCloud3 _pCloud3; |
| | | 14 | | |
| | | 15 | | private Point3[] _data; |
| | | 16 | | |
| | 0 | 17 | | public UpdateMethods() |
| | 0 | 18 | | { |
| | 0 | 19 | | var data = DataLoader.Load(); |
| | 0 | 20 | | _width = data.Item1; |
| | 0 | 21 | | _height = data.Item2; |
| | | 22 | | |
| | | 23 | | |
| | 0 | 24 | | _pCloud3 = new Common.PointCloud3(_width, _height); |
| | 0 | 25 | | _data = data.Item3; |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | [Benchmark] |
| | | 29 | | public void Update() |
| | 0 | 30 | | { |
| | 0 | 31 | | _pCloud3.Update(_data); |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | [Benchmark] |
| | | 35 | | public void UpdateSpan() |
| | 0 | 36 | | { |
| | 0 | 37 | | _pCloud3.Update(_data.AsSpan()); |
| | 0 | 38 | | } |
| | | 39 | | |
| | | 40 | | [Benchmark] |
| | | 41 | | public void UpdateSpan2() |
| | 0 | 42 | | { |
| | 0 | 43 | | _pCloud3.Update2(_data.AsSpan()); |
| | 0 | 44 | | } |
| | | 45 | | |
| | | 46 | | [Benchmark] |
| | | 47 | | public void UpdateMemory() |
| | 0 | 48 | | { |
| | 0 | 49 | | _pCloud3.Update(_data.AsMemory()); |
| | 0 | 50 | | } |
| | | 51 | | |
| | | 52 | | [Benchmark] |
| | | 53 | | public void UpdateMemoryParallel() |
| | 0 | 54 | | { |
| | 0 | 55 | | _pCloud3.UpdateParallel(_data.AsMemory()); |
| | 0 | 56 | | } |
| | | 57 | | |
| | | 58 | | [Benchmark] |
| | | 59 | | public void UpdateParallel() |
| | 0 | 60 | | { |
| | 0 | 61 | | _pCloud3.UpdateParallel(_data); |
| | 0 | 62 | | } |
| | | 63 | | } |