JuliaDSP/DSP.jl — pull request #42 by simonster (2014-06-19 00:45:19+00:00)
Title: Refactored periodogram/spectrogram

- Create a Frequencies type that doesn't need to allocate
- Make arraysplit an AbstractVector, allow simultaneous windowing and padding for FFT
- Periodograms and Spectrograms return objects
- Remove all unnecessary allocations
- Use FFTW plan interface as appropriate

Before:

```
welch_pgram
elapsed time: 2.26281289 seconds (4958061680 bytes allocated, 41.84% gc time)
periodogram
elapsed time: 0.985410854 seconds (2099775920 bytes allocated, 37.71% gc time)
spectrogram
elapsed time: 2.803969485 seconds (5986191280 bytes allocated, 45.00% gc time)
```

With #51:

```
welch_pgram
elapsed time: 1.358011029 seconds (1639007616 bytes allocated, 24.96% gc time)
periodogram
elapsed time: 0.852605558 seconds (1313127760 bytes allocated, 27.78% gc time)
spectrogram
elapsed time: 1.687479602 seconds (2131798512 bytes allocated, 25.07% gc time)
```

With this PR:

```
welch_pgram
elapsed time: 0.26493816 seconds (101397256 bytes allocated, 13.00% gc time)
periodogram
elapsed time: 0.332453868 seconds (527512784 bytes allocated, 31.59% gc time)
spectrogram
elapsed time: 0.381379364 seconds (560135824 bytes allocated, 27.13% gc time)
```

These benchmarks have the same parameters as those from #41 and all performed for two-sided periodograms, but I have performed 1000 iterations instead of 10 so that the GC averages out instead of randomly affecting the benchmarks.

This may be buggy (it passes the existing spectrogram test on Julia 0.3 but `periodogram` and `welch_pgram` are currently untested) and I need to fix the failure on Julia 0.2, but I don't think these things will change the performance.

cc @gummif, @gasagna