From e5818a0071a5b1764b36293dff7be090030fc554 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 13 Aug 2017 16:41:11 -0500 Subject: [PATCH] LogStream: Remove timestamp machinery and memory_consumption --- cmake/checks/check_02_system_features.cmake | 5 - include/deal.II/base/config.h.in | 2 - include/deal.II/base/logstream.h | 67 +----------- source/base/logstream.cc | 114 -------------------- 4 files changed, 1 insertion(+), 187 deletions(-) diff --git a/cmake/checks/check_02_system_features.cmake b/cmake/checks/check_02_system_features.cmake index caaa3f0824..ac41f12f74 100644 --- a/cmake/checks/check_02_system_features.cmake +++ b/cmake/checks/check_02_system_features.cmake @@ -21,9 +21,7 @@ # DEAL_II_HAVE_JN # DEAL_II_HAVE_SYS_RESOURCE_H # DEAL_II_HAVE_SYS_TIME_H -# DEAL_II_HAVE_SYS_TIMES_H # DEAL_II_HAVE_SYS_TYPES_H -# DEAL_II_HAVE_TIMES # DEAL_II_HAVE_UNISTD_H # DEAL_II_MSVC # @@ -42,9 +40,6 @@ CHECK_INCLUDE_FILE_CXX("sys/resource.h" DEAL_II_HAVE_SYS_RESOURCE_H) CHECK_INCLUDE_FILE_CXX("sys/time.h" DEAL_II_HAVE_SYS_TIME_H) -CHECK_INCLUDE_FILE_CXX("sys/times.h" DEAL_II_HAVE_SYS_TIMES_H) -CHECK_CXX_SYMBOL_EXISTS("times" "sys/times.h" DEAL_II_HAVE_TIMES) - CHECK_INCLUDE_FILE_CXX("sys/types.h" DEAL_II_HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILE_CXX("unistd.h" DEAL_II_HAVE_UNISTD_H) diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 4e84a33888..7319dc1285 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -122,12 +122,10 @@ #cmakedefine DEAL_II_HAVE_SYS_RESOURCE_H #cmakedefine DEAL_II_HAVE_SYS_TIME_H -#cmakedefine DEAL_II_HAVE_SYS_TIMES_H #cmakedefine DEAL_II_HAVE_SYS_TYPES_H #cmakedefine DEAL_II_HAVE_UNISTD_H #cmakedefine DEAL_II_HAVE_GETHOSTNAME #cmakedefine DEAL_II_HAVE_GETPID -#cmakedefine DEAL_II_HAVE_TIMES #cmakedefine DEAL_II_HAVE_JN #cmakedefine DEAL_II_MSVC diff --git a/include/deal.II/base/logstream.h b/include/deal.II/base/logstream.h index 6a8d04bd84..0724eb443a 100644 --- a/include/deal.II/base/logstream.h +++ b/include/deal.II/base/logstream.h @@ -28,15 +28,6 @@ #include #include -#ifdef DEAL_II_HAVE_SYS_TIMES_H -# include -#else -struct tms -{ - int tms_utime, tms_stime, tms_cutime, tms_cstime; -}; -#endif - DEAL_II_NAMESPACE_OPEN @@ -226,36 +217,6 @@ public: unsigned int depth_file (const unsigned int n); - /** - * Set time printing flag. If this flag is true, each output line will be - * prepended by the user time used by the running program so far. - * - * The previous value of this parameter is returned. - */ - bool log_execution_time (const bool flag); - - - /** - * Output time differences between consecutive logs. If this function is - * invoked with true, the time difference between the previous log - * line and the recent one is printed. If it is invoked with false, - * the accumulated time since start of the program is printed (default - * behavior). - * - * The measurement of times is not changed by this function, just the - * output. - * - * The previous value of this parameter is returned. - */ - bool log_time_differences (const bool flag); - - - /** - * Write detailed timing information. - */ - void timestamp(); - - /** * Log the thread id. */ @@ -356,44 +317,18 @@ private: */ unsigned int file_depth; - /** - * Flag for printing execution time. - */ - bool print_utime; - - /** - * Flag for printing time differences. - */ - bool diff_utime; - - /** - * Time of last output line. - */ - double last_time; - /** * Flag for printing thread id. */ bool print_thread_id; - /** - * The value times() returned on initialization. - */ - double reference_time_val; - - /** - * The tms structure times() filled on initialization. - */ - struct tms reference_tms; - /** * A flag indicating whether output is currently at a new line */ bool at_newline; /** - * Print head of line. This prints optional time information and the - * contents of the prefix stack. + * Print head of line. */ void print_line_head (); diff --git a/source/base/logstream.cc b/source/base/logstream.cc index 94ebc8f78c..de9757600d 100644 --- a/source/base/logstream.cc +++ b/source/base/logstream.cc @@ -15,17 +15,8 @@ #include #include -#include #include -#ifdef DEAL_II_HAVE_SYS_RESOURCE_H -# include -#endif - -#ifdef DEAL_II_HAVE_UNISTD_H -# include -#endif - #include #include #include @@ -51,18 +42,10 @@ LogStream::LogStream() file(nullptr), std_depth(0), file_depth(10000), - print_utime(false), - diff_utime(false), - last_time (0.), print_thread_id(false), at_newline(true) { get_prefixes().push("DEAL:"); - -#if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_TIMES) - reference_time_val = 1./sysconf(_SC_CLK_TCK) * times(&reference_tms); -#endif - } @@ -307,26 +290,6 @@ LogStream::depth_file (const unsigned int n) } -bool -LogStream::log_execution_time (const bool flag) -{ - Threads::Mutex::ScopedLock lock(log_lock); - const bool h = print_utime; - print_utime = flag; - return h; -} - - -bool -LogStream::log_time_differences (const bool flag) -{ - Threads::Mutex::ScopedLock lock(log_lock); - const bool h = diff_utime; - diff_utime = flag; - return h; -} - - bool LogStream::log_thread_id (const bool flag) { @@ -372,36 +335,11 @@ LogStream::get_prefixes() const void LogStream::print_line_head() { -#ifdef DEAL_II_HAVE_SYS_RESOURCE_H - rusage usage; - double utime = 0.; - if (print_utime) - { - getrusage(RUSAGE_SELF, &usage); - utime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec; - if (diff_utime) - { - double diff = utime - last_time; - last_time = utime; - utime = diff; - } - } -#else -//TODO[BG]: Do something useful here - double utime = 0.; -#endif - const std::string &head = get_prefix(); const unsigned int thread = Threads::this_thread_id(); if (get_prefixes().size() <= std_depth) { - if (print_utime) - { - int p = std_out->width(5); - *std_out << utime << ':'; - std_out->width(p); - } if (print_thread_id) *std_out << '[' << thread << ']'; @@ -411,12 +349,6 @@ LogStream::print_line_head() if (file && (get_prefixes().size() <= file_depth)) { - if (print_utime) - { - int p = file->width(6); - *file << utime << ':'; - file->width(p); - } if (print_thread_id) *file << '[' << thread << ']'; @@ -425,50 +357,4 @@ LogStream::print_line_head() } } - -void -LogStream::timestamp () -{ - struct tms current_tms; -#if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_TIMES) - const clock_t tick = sysconf(_SC_CLK_TCK); - const double time = 1./tick * times(¤t_tms); -#else - const double time = 0.; - const unsigned int tick = 100; - current_tms.tms_utime = 0; - current_tms.tms_stime = 0; - current_tms.tms_cutime = 0; - current_tms.tms_cstime = 0; -#endif - (*this) << "Wall: " << time - reference_time_val - << " User: " << 1./tick * (current_tms.tms_utime - reference_tms.tms_utime) - << " System: " << 1./tick * (current_tms.tms_stime - reference_tms.tms_stime) - << " Child-User: " << 1./tick * (current_tms.tms_cutime - reference_tms.tms_cutime) - << " Child-System: " << 1./tick * (current_tms.tms_cstime - reference_tms.tms_cstime) - << std::endl; -} - - -std::size_t -LogStream::memory_consumption () const -{ - // TODO - Assert(false, ExcNotImplemented()); - - std::size_t mem = sizeof(*this); - // to determine size of stack - // elements, we have to copy the - // stack since we can't access - // elements from further below -// std::stack tmp = prefixes; -// while (tmp.empty() == false) -// { -// mem += MemoryConsumption::memory_consumption (tmp.top()); -// tmp.pop (); -// } - - return mem; -} - DEAL_II_NAMESPACE_CLOSE -- 2.39.5