mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-04 20:01:44 +02:00
Log end to end latencies
This commit is contained in:
parent
136766412c
commit
cdb2227bf5
3 changed files with 44 additions and 17 deletions
|
@ -20,6 +20,7 @@
|
|||
#define DOUBLE_BUFFER_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <deque>
|
||||
|
||||
|
||||
|
@ -90,7 +91,22 @@ public:
|
|||
return 0;
|
||||
std::deque<T> tmpBuffer(buffer.begin(), buffer.end());
|
||||
std::sort(tmpBuffer.begin(), tmpBuffer.end());
|
||||
return tmpBuffer[(size_t)(tmpBuffer.size() * ((float)percentile / (float)100))];
|
||||
return tmpBuffer[(size_t)((tmpBuffer.size() - 1) * ((float)percentile / (float)100))];
|
||||
}
|
||||
|
||||
template <std::size_t Size>
|
||||
std::array<T, Size> percentiles(std::array<uint8_t, Size> percentiles) const
|
||||
{
|
||||
std::array<T, Size> result;
|
||||
result.fill(0);
|
||||
if (buffer.empty())
|
||||
return result;
|
||||
std::deque<T> tmpBuffer(buffer.begin(), buffer.end());
|
||||
std::sort(tmpBuffer.begin(), tmpBuffer.end());
|
||||
for (std::size_t i = 0; i < Size; ++i)
|
||||
result[i] = tmpBuffer[(size_t)((tmpBuffer.size() - 1) * ((float)percentiles[i] / (float)100))];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool full() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue