This commit is contained in:
2026-08-03 08:15:37 +08:00
parent f7bf538449
commit d383b1a6b0
+14
View File
@@ -87,7 +87,9 @@ public:
double smooth{};
double variation{};
double instant{};
double p50{};
double p95{};
double p99{};
size_t times{};
size_t recent_count{};
size_t recent_index{};
@@ -103,7 +105,9 @@ public:
smooth = 0.0;
variation = 0.0;
instant = 0.0;
p50 = 0.0;
p95 = 0.0;
p99 = 0.0;
times = 0;
recent_count = 0;
recent_index = 0;
@@ -118,7 +122,9 @@ public:
Ret_J(smooth)
Ret_J(variation)
Ret_J(instant)
Ret_J(p50)
Ret_J(p95)
Ret_J(p99)
Ret_J(times) return ret;
}
[[nodiscard]] std::string to_string() const {
@@ -160,6 +166,14 @@ private:
if (index > 0)
--index;
p95 = sorted[index];
auto percentile_index = [this](double percentile) {
auto index = static_cast<std::size_t>(std::ceil(static_cast<double>(recent_count) * percentile));
if (index > 0)
--index;
return std::min(index, recent_count - 1);
};
p50 = sorted[percentile_index(0.50)];
p99 = sorted[percentile_index(0.99)];
}
};
class Probability_Statistics : public Base_Statistics {