]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
use of getrusage with RUSAGE_CHILDREN, but still the Timer class does not work in...
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 25 Aug 2000 12:01:26 +0000 (12:01 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 25 Aug 2000 12:01:26 +0000 (12:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@3270 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/timer.h
deal.II/base/source/timer.cc
deal.II/doc/news/2000/c-3-0.html

index 2e9691d37fb0c49613452e69c6bf3152fa2fb630..2d99107a1254ab138a1c66b36cd90b5707614757 100644 (file)
@@ -96,6 +96,29 @@ class Timer
                                      */
     double              start_time;
 
+
+                                    /**
+                                     * Similar to @p{start_time}, but
+                                     * needed for children threads
+                                     * in multithread mode. Value of
+                                     * the user time when @p{start}
+                                     * was called the last time or
+                                     * when the object was created
+                                     * and no @p{stop} was issued in
+                                     * between.
+                                     *
+                                     * For some reason (error in
+                                     * operating system?) the
+                                     * function call
+                                     * @p{getrusage(RUSAGE_CHILDREN,.)}
+                                     * gives always 0 (at least
+                                     * on Solaris7). Hence the
+                                     * @p{Timer} class still does not
+                                     * yet work for multithreading
+                                     * mode.
+                                     */
+    double              start_time_children;
+
                                     /**
                                      * Accumulated time for all previous
                                      * @p{start}/@p{stop} cycles. The time for
index 25e93882ca6f193392047e0e3b71c5235eebbf2c..79fc37c8abe99822a814d6de7f938b47460900cb 100644 (file)
@@ -46,6 +46,10 @@ void Timer::start ()
   rusage usage;
   getrusage (RUSAGE_SELF, &usage);
   start_time = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
+
+  rusage usage_children;
+  getrusage (RUSAGE_CHILDREN, &usage_children);
+  start_time_children = usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec;
 }
 
 
@@ -59,6 +63,12 @@ double Timer::stop ()
       getrusage (RUSAGE_SELF, &usage);
       const double dtime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
       cumulative_time += dtime - start_time;
+
+      rusage usage_children;
+      getrusage (RUSAGE_CHILDREN, &usage_children);
+      const double dtime_children =
+       usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec;
+      cumulative_time += dtime_children - start_time_children;
     }
   return cumulative_time;
 }
@@ -72,8 +82,13 @@ double Timer::operator() () const
       rusage usage;
       getrusage (RUSAGE_SELF, &usage);
       const double dtime =  usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
+      
+      rusage usage_children;
+      getrusage (RUSAGE_CHILDREN, &usage_children);
+      const double dtime_children =
+       usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec;
 
-      return dtime - start_time + cumulative_time;
+      return dtime - start_time + dtime_children - start_time_children + cumulative_time;
     }
   else
     return cumulative_time;
index 4092d480aabdbca410c6acc58c71303963624ed4..cdca5f31987fcd5819588eb2c2b3ca10a79ac8cd 100644 (file)
 <h3>base</h3>
 
 <ol>
+  <li> <p> 
+       New: <code class="class">Timer</code> now uses the system
+       function <code class="member">getrusage (RUSAGE_CHILDREN,
+       .)</code> that is need in multithreading. But still the <code
+       class="class">Timer</code> class does not yet work in
+       multithreading, as getrusage with flag RUSAGE_CHILDREN gives always
+       0 (at least on Solaris7).
+       <br>
+       (Ralf Hartmann 2000/08/25)
+       </p>   
+
   <li> <p>
        New: There are now a set of functions
        <code class="member">outer_product</code> that for the outer

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.