#include <base/config.h>
#include <base/conditional_ostream.h>
+#include <base/thread_management.h>
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
#include <mpi.h>
*/
MPI_Comm mpi_communicator;
#endif
+
+ /**
+ * A lock that makes sure that this
+ * class gives reasonable results even
+ * when used with several threads.
+ */
+
+ Threads::ThreadMutex mutex;
};
DEAL_II_NAMESPACE_CLOSE
#include <sys/time.h>
#include <sys/resource.h>
-#include <base/thread_management.h>
-
// on SunOS 4.x, getrusage is stated in the man pages and exists, but
// is not declared in resource.h. declare it ourselves
void
TimerOutput::enter_section (const std::string §ion_name)
{
- Threads::Mutex mutex;
- Threads::Mutex::ScopedLock lock (mutex);
+ Threads::ThreadMutex::ScopedLock lock (mutex);
Assert (section_name.empty() == false,
ExcMessage ("Section string is empty."));
void
TimerOutput::exit_section (const std::string §ion_name)
{
- Threads::Mutex mutex;
- Threads::Mutex::ScopedLock lock (mutex);
+ Threads::ThreadMutex::ScopedLock lock (mutex);
if (section_name != "")
{
std::cout.width(10);
std::cout.precision(3);
out_stream << " CPU time " << " | % of total |\n";
- out_stream << "+---------------------------------------------+------------"
+ out_stream << "+---------------------------------+-----------+------------"
<< "+------------+";
for (std::map<std::string, Section>::const_iterator
i = sections.begin(); i!=sections.end(); ++i)
out_stream << i->second.total_cpu_time/total_cpu_time * 100 << "% |";
}
out_stream << std::endl
- << "+---------------------------------------------+"
+ << "+---------------------------------+-----------+"
<< "------------+------------+\n"
<< std::endl;
out_stream << "\n\n"
<< "+---------------------------------------------+------------"
<< "+------------+\n"
- << "| Total wallclock time elapsed from start |";
+ << "| Total wallclock time elapsed since start |";
std::cout.width(10);
std::cout.precision(3);
out_stream << total_wall_time << "s | |\n";
std::cout.width(10);
std::cout.precision(3);
out_stream << " wall time | % of total |\n";
- out_stream << "+---------------------------------------------+------------"
+ out_stream << "+---------------------------------+-----------+------------"
<< "+------------+";
for (std::map<std::string, Section>::const_iterator
i = sections.begin(); i!=sections.end(); ++i)
out_stream << i->second.total_wall_time/total_wall_time * 100 << "% |";
}
out_stream << std::endl
- << "+---------------------------------------------+"
+ << "+---------------------------------+-----------+"
<< "------------+------------+\n"
<< std::endl;