From 65379ed4768de933450d90d67ced29eed06b66b8 Mon Sep 17 00:00:00 2001 From: Amber Date: Sat, 4 May 2024 23:22:41 +0300 Subject: [PATCH] Some small optimization of peak finding --- BecquerelMonitor/FWHMPeakDetector/Spectrum.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BecquerelMonitor/FWHMPeakDetector/Spectrum.cs b/BecquerelMonitor/FWHMPeakDetector/Spectrum.cs index d079c15..11a84a7 100644 --- a/BecquerelMonitor/FWHMPeakDetector/Spectrum.cs +++ b/BecquerelMonitor/FWHMPeakDetector/Spectrum.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; namespace BecquerelMonitor.FWHMPeakDetector { @@ -93,11 +94,10 @@ public Spectrum(EnergySpectrum energySpectrum) this.bin_centers_raw = new double[counts.Length + 1]; this.bin_widths_raw = new double[counts.Length + 1]; - for (int i = 0; i < counts.Length; i++) - { + Parallel.For(0, counts.Length, i => { this.counts[i] = Convert.ToDouble(energySpectrum.Spectrum[i]); this.bin_edges_raw[i] = Convert.ToDouble(i); - } + }); this.bin_edges_raw[counts.Length] = Convert.ToDouble(counts.Length);