16 #include <deal.II/base/logstream.h> 17 #include <deal.II/base/job_identifier.h> 18 #include <deal.II/base/memory_consumption.h> 19 #include <deal.II/base/thread_management.h> 21 #ifdef DEAL_II_HAVE_SYS_RESOURCE_H 22 # include <sys/resource.h> 25 #ifdef DEAL_II_HAVE_UNISTD_H 35 DEAL_II_NAMESPACE_OPEN
65 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_TIMES) 93 if ((
this == &deallog) &&
file)
94 std::cerr << (
"You still have content that was written to 'deallog' " 95 "but not flushed to the screen or a file while the " 96 "program is being terminated. This would lead to a " 97 "segmentation fault. Make sure you flush the " 98 "content of the 'deallog' object using 'std::endl' " 99 "before the end of the program.")
157 class QueryStreambuf :
public std::streambuf
163 : flushed_(
false), newline_written_(
false)
170 bool newline_written()
172 return newline_written_;
175 int_type overflow(int_type ch)
177 newline_written_ =
true;
186 bool newline_written_;
191 std::ostream inject (&query_streambuf);
195 if (query_streambuf.flushed())
203 at_newline = query_streambuf.newline_written();
209 *
file << stream.str() << std::flush;
221 const bool print_job_id)
225 o.setf(std::ios::showpoint | std::ios::left);
278 static std::string empty_string;
295 pre += std::string(
":");
393 std::stack<std::string> &
396 #ifdef DEAL_II_WITH_THREADS 398 std::stack<std::string> &local_prefixes =
prefixes.
get(exists);
404 const tbb::enumerable_thread_specific<std::stack<std::string> > &impl
409 const tbb::enumerable_thread_specific<std::stack<std::string> >::const_iterator first_elem
412 if (first_elem != impl.end())
414 local_prefixes = *first_elem;
418 return local_prefixes;
429 #ifdef DEAL_II_HAVE_SYS_RESOURCE_H 434 getrusage(RUSAGE_SELF, &usage);
435 utime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
460 *
std_out <<
'[' << thread <<
']';
470 int p =
file->width(6);
471 *
file << utime <<
':';
475 *
file <<
'[' << thread <<
']';
478 *
file << head <<
':';
486 struct tms current_tms;
487 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_TIMES) 488 const clock_t tick = sysconf(_SC_CLK_TCK);
489 const double time = 1./tick * times(¤t_tms);
491 const double time = 0.;
492 const unsigned int tick = 100;
493 current_tms.tms_utime = 0;
494 current_tms.tms_stime = 0;
495 current_tms.tms_cutime = 0;
496 current_tms.tms_cstime = 0;
499 <<
" User: " << 1./tick * (current_tms.tms_utime -
reference_tms.tms_utime)
500 <<
" System: " << 1./tick * (current_tms.tms_stime -
reference_tms.tms_stime)
501 <<
" Child-User: " << 1./tick * (current_tms.tms_cutime -
reference_tms.tms_cutime)
502 <<
" Child-System: " << 1./tick * (current_tms.tms_cstime -
reference_tms.tms_cstime)
511 Assert(
false, ExcNotImplemented());
513 std::size_t mem =
sizeof(*this);
528 DEAL_II_NAMESPACE_CLOSE
std::streamsize precision(const std::streamsize prec)
unsigned int this_thread_id()
Threads::ThreadLocalStorage< std::stack< std::string > > prefixes
const std::string & get_prefix() const
void test_mode(bool on=true)
void threshold_double(const double t)
unsigned int depth_file(const unsigned int n)
std::streamsize width(const std::streamsize wide)
bool log_thread_id(const bool flag)
std::ostream & get_file_stream()
std::streambuf * old_cerr
std::ios::fmtflags flags(const std::ios::fmtflags f)
LogStream & operator<<(const double t)
#define Assert(cond, exc)
tbb::enumerable_thread_specific< T > & get_implementation()
std::stack< std::string > & get_prefixes() const
void threshold_float(const float t)
bool log_time_differences(const bool flag)
unsigned int depth_console(const unsigned int n)
void attach(std::ostream &o, const bool print_job_id=true)
std::ostream & get_console()
double reference_time_val
bool log_execution_time(const bool flag)
void push(const std::string &text)
std::ostringstream & get_stream()
std::size_t memory_consumption() const