File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,40 @@ coverage: 100.0% of statements
103103ok github.com/MicahParks/peakdetect 0.019s
104104```
105105
106+ # Performance
107+ To further improve performance, this algorithm uses Welford's algorithm on initialization
108+ and an adaptation of [ this StackOverflow answer] ( https://stackoverflow.com/a/14638138/14797322 ) to calculate the mean
109+ and population standard deviation for the lag period (sliding window). This appears to improve performance by more than
110+ a factor of 10!
111+
112+ ` v0.0.4 `
113+ ```
114+ goos: linux
115+ goarch: amd64
116+ pkg: github.com/MicahParks/peakdetect
117+ cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
118+ BenchmarkPeakDetector_NextBatch
119+ BenchmarkPeakDetector_NextBatch-6 1000000000 0.0000278 ns/op
120+ PASS
121+ ```
122+
123+ ` v0.0.5 `
124+ ```
125+ goos: linux
126+ goarch: amd64
127+ pkg: github.com/MicahParks/peakdetect
128+ cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
129+ BenchmarkPeakDetector_NextBatch-6 1000000000 0.0000013 ns/op
130+ PASS
131+ ok github.com/MicahParks/peakdetect 0.002s
132+ ```
133+
106134# References
107135Brakel, J.P.G. van (2014). "Robust peak detection algorithm using z-scores". Stack Overflow. Available
108136at: https://stackoverflow.com/questions/22583391/peak-signal-detection-in-realtime-timeseries-data/22640362#22640362
109137(version: 2020-11-08).
138+
139+ * [ StackOverflow: Peak detection in realtime timeseries data] ( https://stackoverflow.com/a/22640362/14797322 ) .
140+ * [ StackOverflow: sliding window for online algorithm to calculate mean and standard devation] ( https://stackoverflow.com/a/14637676/14797322 )
141+ * [ Welford's algorithm related blog post] ( https://www.johndcook.com/blog/standard_deviation/ ) .
142+ * Yeah, I used [ Wikipedia] ( https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance ) too.
You can’t perform that action at this time.
0 commit comments