jurihock / qdft

Constant-Q Sliding DFT in C++, Rust and Python
MIT License
31 stars 3 forks source link

Optimize circular buffer shift in the C++ implementation #4

Closed jurihock closed 1 year ago

jurihock commented 1 year ago

As mentioned in my comment, the std::rotate is most likely a major performance issue.

Actually there is no measurable difference between the following variations:

But instead of std::vector use std::deque to shift the buffered values like so:

The complexity of the linear/random element access as well as insertion or removal of elements at both ends of the std::deque should be still O(1).

jurihock commented 1 year ago

Benchmark

Test case:

Results:

std::deque is clearly the winner!