changeset 754:d7c34b3f0b51

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 14 Apr 2026 15:43:04 +0200
parents e4ef25e1fcba (current diff) 3e7a9e980269 (diff)
children 161293383661
files Plugin/WeightedAverageMetrics.h
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/WeightedAverageMetrics.h	Tue Apr 14 15:42:56 2026 +0200
+++ b/Plugin/WeightedAverageMetrics.h	Tue Apr 14 15:43:04 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,6 +74,10 @@
         {
           oldest = values_.front();
         }
+        else
+        {
+          return;
+        }
       }
     }
   }