Przeglądaj źródła

Merge pull request #727 from yuriks/profiler-fix

Profiler: Fix off-by-one error when computing average.
archshift 11 lat temu
rodzic
commit
acc242f6f1
1 zmienionych plików z 1 dodań i 2 usunięć
  1. 1 2
      src/common/profiler.cpp

+ 1 - 2
src/common/profiler.cpp

@@ -126,10 +126,9 @@ void TimingResultsAggregator::AddFrame(const ProfilingFrameResult& frame_result)
 static AggregatedDuration AggregateField(const std::vector<Duration>& v, size_t len) {
 static AggregatedDuration AggregateField(const std::vector<Duration>& v, size_t len) {
     AggregatedDuration result;
     AggregatedDuration result;
     result.avg = Duration::zero();
     result.avg = Duration::zero();
-
     result.min = result.max = (len == 0 ? Duration::zero() : v[0]);
     result.min = result.max = (len == 0 ? Duration::zero() : v[0]);
 
 
-    for (size_t i = 1; i < len; ++i) {
+    for (size_t i = 0; i < len; ++i) {
         Duration value = v[i];
         Duration value = v[i];
         result.avg += value;
         result.avg += value;
         result.min = std::min(result.min, value);
         result.min = std::min(result.min, value);