From a3418f7002afc3f8bbdf384813f222709af85ff2 Mon Sep 17 00:00:00 2001
From: Florian Fischer <florian.fischer@muhq.space>
Date: Mon, 28 Feb 2022 15:41:26 +0100
Subject: [PATCH] print blocked context FromAnywhere stats when
 STATS_BLOCKED_CONTEXT is set

This is analogue to what we do in emper/stats/worker.cpp since 46302a0.
---
 emper/stats/FromAnywhere.cpp | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/emper/stats/FromAnywhere.cpp b/emper/stats/FromAnywhere.cpp
index 455e405f..2459dd62 100644
--- a/emper/stats/FromAnywhere.cpp
+++ b/emper/stats/FromAnywhere.cpp
@@ -5,6 +5,8 @@
 #include <memory>
 #include <string>
 
+#include "Emper.hpp"
+
 using namespace emper::stats;
 
 FromAnywhere::FromAnywhere(workerid_t workerCount)
@@ -24,22 +26,26 @@ void FromAnywhere::recordUnblockedContext(workeraffinity_t workerAffinity,
 }
 
 auto FromAnywhere::operator+=(const FromAnywhere& other) -> FromAnywhere& {
-	for (decltype(unblockAffinitiesGeneric)::size_type i = 0; i < unblockAffinitiesGeneric.size();
-			 i++) {
-		unblockAffinitiesGeneric[i] += other.unblockAffinitiesGeneric[i];
-		unblockAffinitiesIo[i] += other.unblockAffinitiesIo[i];
+	if constexpr (emper::STATS_BLOCKED_CONTEXT) {
+		for (decltype(unblockAffinitiesGeneric)::size_type i = 0; i < unblockAffinitiesGeneric.size();
+				 i++) {
+			unblockAffinitiesGeneric[i] += other.unblockAffinitiesGeneric[i];
+			unblockAffinitiesIo[i] += other.unblockAffinitiesIo[i];
+		}
 	}
 	return *this;
 }
 
 void FromAnywhere::print(std::ostream& out) {
-	for (decltype(unblockAffinitiesGeneric)::size_type i = 0; i < unblockAffinitiesGeneric.size();
-			 ++i) {
-		out << "unblock-affinities-fa-generic" << std::to_string(i) << ": "
-				<< std::to_string(unblockAffinitiesGeneric[i]) << std::endl;
-	}
-	for (decltype(unblockAffinitiesIo)::size_type i = 0; i < unblockAffinitiesIo.size(); ++i) {
-		out << "unblock-affinities-fa-io" << std::to_string(i) << ": "
-				<< std::to_string(unblockAffinitiesIo[i]) << std::endl;
+	if constexpr (emper::STATS_BLOCKED_CONTEXT) {
+		for (decltype(unblockAffinitiesGeneric)::size_type i = 0; i < unblockAffinitiesGeneric.size();
+				 ++i) {
+			out << "unblock-affinities-fa-generic" << std::to_string(i) << ": "
+					<< std::to_string(unblockAffinitiesGeneric[i]) << std::endl;
+		}
+		for (decltype(unblockAffinitiesIo)::size_type i = 0; i < unblockAffinitiesIo.size(); ++i) {
+			out << "unblock-affinities-fa-io" << std::to_string(i) << ": "
+					<< std::to_string(unblockAffinitiesIo[i]) << std::endl;
+		}
 	}
 }
-- 
GitLab