Skip to content

Commit

Permalink
Move out file
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Dec 27, 2024
1 parent 30fd144 commit 5574c69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endmacro()

target(debug_client client.cpp)
target(debug_server server.cpp)
target(debug_percentiles percentiles2.cpp)
target(kv kv.cpp)

if (SQLite3_FOUND)
Expand Down
9 changes: 4 additions & 5 deletions client/percentiles2.cpp → examples/percentiles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SlidingWindowPercentile {

uint64_t getPercentile(int targetPercentile) {
if (windowSorted.empty()) {
return -1; // Окно пусто
return -1;
}

int index = (targetPercentile * windowSorted.size()) / 100;
Expand All @@ -40,14 +40,13 @@ class SlidingWindowPercentile {
}

private:
std::queue<uint64_t> windowQueue; // Сохраняет элементы в порядке их добавления
std::multiset<uint64_t> windowSorted; // Отсортированные элементы окна
std::queue<uint64_t> windowQueue;
std::multiset<uint64_t> windowSorted;
int windowSize;
};

int main() {
// Пример использования
SlidingWindowPercentile calculator(1000000); // 50-й перцентиль с размером окна 5
SlidingWindowPercentile calculator(1000000);
vector<int> p = {50, 80, 90, 99};
uint64_t num;

Expand Down

0 comments on commit 5574c69

Please sign in to comment.