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

[Runtime] print stats in the destructor not at exit

parent 25d01022
No related branches found
No related tags found
1 merge request!147[Runtime] print stats in the destructor not at exit
......@@ -99,7 +99,6 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategyFactory& strategyFactory
if constexpr (emper::STATS) {
globalIo->stats.workerId = emper::io::Stats::GLOBAL_COMPLETER_ID;
std::atexit(emper::io::Stats::printWorkerStats);
}
}
......@@ -148,13 +147,6 @@ Runtime::Runtime(workerid_t workerCount, RuntimeStrategyFactory& strategyFactory
threadsRunning = true;
if constexpr (emper::STATS) {
int res = std::atexit(&printLastRuntimeStats);
if (res) {
DIE_MSG("could not register printStats() with at_exit()");
}
}
const std::string stacktraceOnAbortsEnvVar("EMPER_STACKTRACE_ON_ABORTS");
const char* envValueEnableStacktraces = std::getenv(stacktraceOnAbortsEnvVar.c_str());
if (envValueEnableStacktraces && !std::strcmp(envValueEnableStacktraces, "true")) {
......@@ -169,6 +161,13 @@ Runtime::~Runtime() {
initiateAndWaitUntilTermination();
}
// Print the stats after all worker threads have terminated and before we delete
// objects bound to the runtime's lifetime
if constexpr (emper::STATS) {
printLastRuntimeStats();
emper::io::Stats::printWorkerStats();
}
for (unsigned int i = 0; i < workerCount; ++i) {
delete workers[i];
}
......
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