| | 1 | | using BenchmarkDotNet.Attributes; |
| | 2 | | using Implementation.Components; |
| | 3 | | using PointCloud.Benchmark.Interactivity; |
| | 4 | | using PointCloud.Benchmark.Util; |
| | 5 | | using ReFlex.Core.Common.Components; |
| | 6 | | using ReFlex.Core.Common.Util; |
| | 7 | |
|
| | 8 | | namespace PointCloud.Benchmark.Benchmarks.Interactivity; |
| | 9 | |
|
| | 10 | | [MemoryDiagnoser] |
| | 11 | | public class MultiInteractionObserverBenchmark |
| | 12 | | { |
| | 13 | | private int _width; |
| | 14 | | private int _height; |
| | 15 | |
|
| | 16 | | private readonly PointCloud3 _pCloud3; |
| | 17 | | private readonly VectorField2 _vectorfield; |
| | 18 | |
|
| | 19 | | private readonly MultiInteractionObserver _observer; |
| | 20 | |
|
| | 21 | | private Point3[] _data; |
| | 22 | |
|
| 0 | 23 | | public MultiInteractionObserverBenchmark() |
| 0 | 24 | | { |
| 0 | 25 | | var data = DataLoader.Load(0); |
| 0 | 26 | | _width = data.Item1; |
| 0 | 27 | | _height = data.Item2; |
| 0 | 28 | | _data = data.Item3; |
| | 29 | |
|
| 0 | 30 | | _pCloud3 = new PointCloud3(_width, _height); |
| 0 | 31 | | _pCloud3.Update(data.Item3, 0f); |
| | 32 | |
|
| 0 | 33 | | var filterMgr = new FilterManager(); |
| 0 | 34 | | filterMgr.LimitationFilter.LeftBound = 42; |
| 0 | 35 | | filterMgr.LimitationFilter.RightBound = 613; |
| 0 | 36 | | filterMgr.LimitationFilter.LeftBound = 136; |
| 0 | 37 | | filterMgr.LimitationFilter.LeftBound = 413; |
| | 38 | |
|
| 0 | 39 | | filterMgr.IsLimitationFilterEnabled = true; |
| 0 | 40 | | filterMgr.IsBoxFilterEnabled = true; |
| 0 | 41 | | filterMgr.IsValueFilterEnabled = true; |
| 0 | 42 | | filterMgr.MeasurePerformance = false; |
| 0 | 43 | | filterMgr.IsThresholdFilterEnabled = true; |
| | 44 | |
|
| 0 | 45 | | filterMgr.LimitationFilterType = LimitationFilterType.LimitationFilter; |
| | 46 | |
|
| 0 | 47 | | filterMgr.FilterAndUpdate(_data, _pCloud3); |
| | 48 | |
|
| 0 | 49 | | _vectorfield = new VectorField2(_width, _height, 1); |
| 0 | 50 | | _vectorfield.Populate(_pCloud3); |
| | 51 | |
|
| 0 | 52 | | _observer = new MultiInteractionObserver(); |
| 0 | 53 | | _observer.PointCloud = _pCloud3; |
| 0 | 54 | | _observer.VectorField = _vectorfield; |
| | 55 | |
|
| 0 | 56 | | _observer.MinDistance = 0.04f; |
| 0 | 57 | | _observer.MaxDistance = 0.3f; |
| 0 | 58 | | _observer.Distance = 1.45f; |
| 0 | 59 | | _observer.MinAngle = 0.5f; |
| 0 | 60 | | _observer.TouchMergeDistance2D = 19; |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | [Benchmark] |
| | 64 | | public async Task<ProcessingResult> Update() |
| 0 | 65 | | { |
| 0 | 66 | | var result = await _observer.Update(); |
| | 67 | |
|
| 0 | 68 | | return result; |
| 0 | 69 | | } |
| | 70 | |
|
| | 71 | | [Benchmark] |
| | 72 | | public void UpdateVectorField() |
| 0 | 73 | | { |
| 0 | 74 | | _observer.UpdateVectorfield(); |
| 0 | 75 | | } |
| | 76 | |
|
| | 77 | | [Benchmark] |
| | 78 | | public void UpdateVectorFieldParallel() |
| 0 | 79 | | { |
| 0 | 80 | | _observer.UpdateVectorfieldParallel(); |
| 0 | 81 | | } |
| | 82 | |
|
| | 83 | | [Benchmark] |
| | 84 | | public void UpdateVectorFieldParallelStepped() |
| 0 | 85 | | { |
| 0 | 86 | | _observer.UpdateVectorfieldParallelStepped(); |
| 0 | 87 | | } |
| | 88 | |
|
| | 89 | | [Benchmark] |
| | 90 | | public void UpdateVectorFieldStepped1d() |
| 0 | 91 | | { |
| 0 | 92 | | _observer.UpdateVectorfieldStepped1d(); |
| 0 | 93 | | } |
| | 94 | |
|
| | 95 | | [Benchmark] |
| | 96 | | public void UpdateVectorFieldSteppedParallel1d() |
| 0 | 97 | | { |
| 0 | 98 | | _observer.UpdateVectorfieldSteppedParallel1d(); |
| 0 | 99 | | } |
| | 100 | | } |