Mercurial > hg > orthanc-dicomweb
changeset 752:3e7a9e980269
doc + cppcheck in WeightedAverageMetrics
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 14 Apr 2026 15:40:48 +0200 |
| parents | d0bdedd75ff7 |
| children | d7c34b3f0b51 |
| files | Plugin/WeightedAverageMetrics.h |
| diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/WeightedAverageMetrics.h Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/WeightedAverageMetrics.h Tue Apr 14 15:40:48 2026 +0200 @@ -29,6 +29,10 @@ #include <stdint.h> +// This class is used to compute e.g: the average throughput +// of all WADO-RS retrievals over a period of time. For each call, we +// give a value (in this case: the throughput) and a weight (a large request +// has more weight than a small request). template <typename T> class WeightedAverageMetrics : public boost::noncopyable { @@ -60,7 +64,7 @@ if (values_.size() > 0) { - Value& oldest = values_.front(); + Value oldest = values_.front(); while ((now - oldest.time_).total_seconds() > duration_) { totalWeightedValue_ -= oldest.value_ * oldest.weight_; @@ -70,12 +74,16 @@ { oldest = values_.front(); } + else + { + return; + } } } } public: - WeightedAverageMetrics(int64_t duration) : + explicit WeightedAverageMetrics(int64_t duration) : totalWeightedValue_(0), totalWeight_(0), duration_(duration)
