42 #ifndef TEUCHOS_PERFORMANCEMONITORBASE_H 43 #define TEUCHOS_PERFORMANCEMONITORBASE_H 52 #include "Teuchos_Comm.hpp" 94 const Array<std::string>& localNames,
95 Array<std::string>& globalNames,
147 : counter_(counter_in), isRecursiveCall_(counter_.isRunning())
150 counter_.incrementNumCalls ();
185 static void freeTableFormat () {
186 if (format_ != NULL) {
201 static void freeCounters () {
202 if (counters_ != NULL) {
219 if (format_ == NULL) {
225 (void) atexit (freeTableFormat);
228 format_ == NULL, std::logic_error,
"Teuchos::PerformanceMonitorBase::" 229 "format: Should never get here! format_ is NULL.");
278 static TEUCHOS_DEPRECATED
void clearTimer (
const std::string& name);
302 if (counters_ == NULL) {
303 counters_ =
new std::map<std::string, RCP<T> > ();
308 (void) atexit (freeCounters);
311 counters_ == NULL, std::logic_error,
"Teuchos::PerformanceMonitorBase::" 312 "counters: Should never get here! counters_ is NULL.");
322 static std::map<std::string, RCP<T> >* counters_;
328 bool isRecursiveCall_;
333 PerformanceMonitorBase<T>::format_ = NULL;
336 std::map<std::string, RCP<T> >*
337 PerformanceMonitorBase<T>::counters_ = NULL;
343 typedef std::map<std::string, RCP<T> > map_type;
344 typedef typename map_type::iterator iter_type;
346 map_type& ctrs = counters ();
347 iter_type it = ctrs.find (name);
349 if (it == ctrs.end ()) {
350 newCounter =
rcp (
new T (name));
351 #ifdef HAVE_TEUCHOS_DEBUG 352 const bool wasNotThere = ctrs.insert (std::make_pair (name, newCounter)).second;
354 ! wasNotThere, std::logic_error,
355 "getNewCounter: insert() claims that timer \"" << name <<
"\" was " 356 "already there in the map, even though find() claims that it was not. " 357 "Please report this bug to the Teuchos developers.");
360 ctrs.insert (it, std::make_pair (name, newCounter));
361 #endif // HAVE_TEUCHOS_DEBUG 363 newCounter = it->second;
364 #ifdef HAVE_TEUCHOS_DEBUG 366 it->second.is_null (), std::logic_error,
367 "getNewCounter: Timer \"" << name <<
"\" was already there in the map, " 368 "but looking it up by name resulted in a null timer. " 369 "Please report this bug to the Teuchos developers.");
371 name != it->second->name (), std::logic_error,
372 "getNewCounter: Timer \"" << name <<
"\" was already there in the map, " 373 "but looking it up by name resulted in a timer with a different name \"" 374 << it->second->name () <<
"\". Please report this bug to the Teuchos " 376 #endif // HAVE_TEUCHOS_DEBUG 379 #ifdef HAVE_TEUCHOS_DEBUG 381 newCounter.
is_null (), std::logic_error,
382 "getNewCounter: At end of method, when creating timer \"" << name
383 <<
"\", newCounter is null. Please report this bug to the Teuchos " 385 #endif // HAVE_TEUCHOS_DEBUG 393 typedef std::map<std::string, RCP<T> > map_type;
394 typedef typename map_type::iterator iter_type;
396 map_type& ctrs = counters ();
397 iter_type it = ctrs.find (name);
398 if (it == ctrs.end ()) {
409 counters ().erase (name);
430 counters ().clear ();
435 #endif // TEUCHOS_PERFORMANCEMONITORBASE_H
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
bool is_null() const
Returns true if the underlying pointer is null.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
void mergeCounterNames(const Comm< int > &comm, const Array< std::string > &localNames, Array< std::string > &globalNames, const ECounterSetOp setOp)
Merge counter names over all processors.
Templated array class derived from the STL std::vector.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
Smart reference counting pointer class for automatic garbage collection.
ECounterSetOp
Set operation type for mergeCounterNames() to perform.
Reference-counted pointer class and non-member templated function implementations.