diff --git a/primitives/primproc/batchprimitiveprocessor.cpp b/primitives/primproc/batchprimitiveprocessor.cpp index 7bde58dbd..e2291da1a 100644 --- a/primitives/primproc/batchprimitiveprocessor.cpp +++ b/primitives/primproc/batchprimitiveprocessor.cpp @@ -2155,11 +2155,15 @@ void BatchPrimitiveProcessor::makeResponse() int BatchPrimitiveProcessor::operator()() { utils::setThreadName("PPBatchPrimProc"); +#ifdef PRIMPROC_STOPWATCH + const static std::string msg{"BatchPrimitiveProcessor::operator()"}; + logging::StopWatch* stopwatch = nullptr; +#endif + if (currentBlockOffset == 0) { -#ifdef PRIMPROC_STOPWATCH // TODO: needs to be brought up-to-date - map::iterator stopwatchMapIter = stopwatchMap.find(pthread_self()); - logging::StopWatch* stopwatch; +#ifdef PRIMPROC_STOPWATCH + auto stopwatchMapIter = stopwatchMap.find(pthread_self()); if (stopwatchMapIter != stopwatchMap.end()) { @@ -2169,7 +2173,7 @@ int BatchPrimitiveProcessor::operator()() { pthread_mutex_lock(&stopwatchMapMutex); stopwatch = new logging::StopWatch(stopwatchMap.size()); - stopwatchMap.insert(make_pair(pthread_self(), stopwatch)); + stopwatchMap.insert({pthread_self(), stopwatch}); // Create the thread that will show timing results after five seconds of idle time. if (!stopwatchThreadCreated) @@ -2186,9 +2190,6 @@ int BatchPrimitiveProcessor::operator()() pthread_mutex_unlock(&stopwatchMapMutex); } - ostringstream oss; - oss << "BatchPrimitiveProcessor::operator()"; - string msg = oss.str(); stopwatch->start(msg); #endif diff --git a/primitives/primproc/primitiveserver.cpp b/primitives/primproc/primitiveserver.cpp index 704692385..5faddf35d 100644 --- a/primitives/primproc/primitiveserver.cpp +++ b/primitives/primproc/primitiveserver.cpp @@ -2628,7 +2628,7 @@ bool BPPV::aborted() } #ifdef PRIMPROC_STOPWATCH -map stopwatchMap; +std::unordered_map stopwatchMap; pthread_mutex_t stopwatchMapMutex; bool stopwatchThreadCreated = false; @@ -2670,7 +2670,7 @@ void* autoFinishStopwatchThread(void* arg) pause_(2); count++; // Iterate through the stopwatch map and see how long it's been since last activity. - map::iterator stopwatchMapIter = stopwatchMap.begin(); + auto stopwatchMapIter = stopwatchMap.begin(); logging::StopWatch* stopwatch; gettimeofday(&tvCurrent, 0); bool primProcIdle = true; diff --git a/primitives/primproc/primitiveserver.h b/primitives/primproc/primitiveserver.h index 033b9fbf8..5d423c34f 100644 --- a/primitives/primproc/primitiveserver.h +++ b/primitives/primproc/primitiveserver.h @@ -32,6 +32,7 @@ #else #include #include +#include #endif #include @@ -60,7 +61,7 @@ extern boost::mutex bppLock; extern uint32_t highPriorityThreads, medPriorityThreads, lowPriorityThreads; #ifdef PRIMPROC_STOPWATCH -extern std::map stopwatchMap; +extern std::unordered_map stopwatchMap; extern pthread_mutex_t stopwatchMapMutex; extern bool stopwatchThreadCreated;