Skip to content
Snippets Groups Projects
Commit bafe87b9 authored by Florian Fischer's avatar Florian Fischer
Browse files

[io/Stats] introduce named constants for special workerIds

parent 6f7d534c
No related branches found
No related tags found
1 merge request!148[io/Stats] introduce named constants for special workerIds
......@@ -97,7 +97,7 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategyFactory& strategyFactory
}
if constexpr (emper::STATS) {
globalIo->stats.workerId = -1;
globalIo->stats.workerId = emper::io::Stats::GLOBAL_COMPLETER_ID;
std::atexit(emper::io::Stats::printWorkerStats);
}
}
......
......@@ -41,7 +41,7 @@ auto operator<<(std::ostream& os, const Stats::CompletionType& t) -> std::ostrea
}
auto operator<<(std::ostream& os, const Stats& s) -> std::ostream& {
if (s.workerId == -1) {
if (s.workerId == Stats::GLOBAL_COMPLETER_ID) {
bool futuresToPrint = false;
std::stringstream ss;
ss << "# global IO Stats: #" << std::endl;
......@@ -72,7 +72,7 @@ auto operator<<(std::ostream& os, const Stats& s) -> std::ostream& {
return os;
}
if (s.workerId == -2) {
if (s.workerId == Stats::AVG_ID) {
os << "# AVG IO worker Stats: #" << std::endl;
} else {
os << "# IO Stats of worker " << std::to_string(s.workerId) << ": #" << std::endl;
......@@ -95,7 +95,7 @@ auto operator<<(std::ostream& os, const Stats& s) -> std::ostream& {
os << std::endl;
}
if (s.workerId == -1) {
if (s.workerId == Stats::GLOBAL_COMPLETER_ID) {
return os;
}
......@@ -126,7 +126,7 @@ void Stats::printWorkerStats() {
// Use a stats object to calculate the averages
Stats avgs;
// mark as averages
avgs.workerId = -2;
avgs.workerId = Stats::AVG_ID;
// calculate avgs
int i = 1;
......
......@@ -46,6 +46,9 @@ class Stats {
friend class RecvFuture;
friend class WritevFuture;
static const int GLOBAL_COMPLETER_ID = -1;
static const int AVG_ID = -2;
int workerId = 0;
static_assert(sizeof(int) > sizeof(workerid_t));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment