| | 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 ConfidenceFilterBenchmark |
| | 12 | | { |
| | 13 | | private int _width; |
| | 14 | | private int _height; |
| | 15 | |
|
| | 16 | | private readonly ReFlex.Core.Common.Components.PointCloud3 _pCloud3; |
| | 17 | | private readonly VectorField2 _vectorfield; |
| | 18 | |
|
| | 19 | | private readonly MultiInteractionObserver _observer; |
| | 20 | |
|
| | 21 | | private Point3[] _data; |
| | 22 | |
|
| 0 | 23 | | public ConfidenceFilterBenchmark() |
| 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; |
| | 61 | |
|
| 0 | 62 | | Task.WaitAny(_observer.Update()); |
| 0 | 63 | | } |
| | 64 | |
|
| | 65 | | [Benchmark] |
| | 66 | | public Interaction[] FilterInteractions1() |
| 0 | 67 | | { |
| 0 | 68 | | return _observer.ApplyConfidenceFilter1().ToArray(); |
| 0 | 69 | | } |
| | 70 | |
|
| | 71 | | [Benchmark] |
| | 72 | | public Interaction[] FilterInteractions2() |
| 0 | 73 | | { |
| 0 | 74 | | return _observer.ApplyConfidenceFilter2().ToArray(); |
| 0 | 75 | | } |
| | 76 | |
|
| | 77 | | [Benchmark] |
| | 78 | | public Interaction[] FilterInteractions3() |
| 0 | 79 | | { |
| 0 | 80 | | return _observer.ApplyConfidenceFilter3().ToArray(); |
| 0 | 81 | | } |
| | 82 | |
|
| | 83 | | [Benchmark] |
| | 84 | | public Interaction[] FilterInteractions4() |
| 0 | 85 | | { |
| 0 | 86 | | return _observer.ApplyConfidenceFilter4().ToArray(); |
| 0 | 87 | | } |
| | 88 | | } |