Closed jurihock closed 1 year ago
Benchmark
Test case:
analysis.cpp
Results:
cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build . && time ./qdft-example-analysis
std::vector ➡ 2.57s user 0.13s system 99% cpu 2.698 total
std::deque ➡ 0.37s user 0.11s system 99% cpu 0.486 total
std::deque
is clearly the winner!
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:
std::rotate(inputs.begin(), inputs.begin() + 1, inputs.end());
std::copy(inputs.begin() + 1, inputs.end(), inputs.begin());
std::shift_left(inputs.begin(), inputs.end(), 1);
But instead of
std::vector
usestd::deque
to shift the buffered values like so:inputs.pop_front();
inputs.push_back(sample);
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).