Skip to content

Commit

Permalink
fix stopwatch stats bug
Browse files Browse the repository at this point in the history
  • Loading branch information
strasdat committed Jul 31, 2024
1 parent e18749e commit 5c80425
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cpp/farm_ng/core/misc/stopwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ class StopwatchSingleton {
for (auto const& t : sliding_window) {
sorted.push_back(t);
}
std::sort(sorted.begin(), sorted.end());

// intentially done before sorting
stats.last = sorted.back();
stats.second_last = sorted.size() > 1 ? sorted[sorted.size() - 2] : -1.0;

// now sort
std::sort(sorted.begin(), sorted.end());

stats.min = sorted.front();
stats.max = sorted.back();
stats.median = sorted[sorted.size() / 2];
Expand Down

0 comments on commit 5c80425

Please sign in to comment.