From 95c3fdd73d7a38414effc538c44eabdaf6b042df Mon Sep 17 00:00:00 2001 From: Benjamin Faigle <benjamin.faigle@posteo.de> Date: Mon, 5 Dec 2011 14:31:34 +0000 Subject: [PATCH] The timer for the cpu time (wall time) in run() method is now acessible from outside (i.e. from problem) via an access function wallTime() git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@6943 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/common/timemanager.hh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dumux/common/timemanager.hh b/dumux/common/timemanager.hh index 4a36def516..b12b46fc92 100644 --- a/dumux/common/timemanager.hh +++ b/dumux/common/timemanager.hh @@ -175,6 +175,12 @@ public: void setEndTime(Scalar t) { endTime_ = t; } + /*! + * \brief Returns the current wall time (cpu time). + */ + double wallTime() const + { return timer_.elapsed(); } + /*! * \brief Set the current time step size to a given value. * @@ -352,8 +358,7 @@ public: */ void run() { - Dune::Timer timer; - timer.reset(); + timer_.reset(); // do the time steps while (!finished()) @@ -382,7 +387,7 @@ public: if (verbose_) { std::cout << boost::format("Time step %d done. Wall time:%.4g, time:%.4g, time step size:%.4g\n") - %timeStepIndex()%timer.elapsed()%time()%dt; + %timeStepIndex()%timer_.elapsed()%time()%dt; } // write restart file if mandated by the problem @@ -406,9 +411,9 @@ public: if (verbose_) { int numProcesses = Dune::MPIHelper::getCollectiveCommunication().size(); - std::cout << "Simulation took " << timer.elapsed() <<" seconds on " + std::cout << "Simulation took " << timer_.elapsed() <<" seconds on " << numProcesses << " processes.\n" - << "The cumulative CPU time was " << timer.elapsed()*numProcesses << " seconds.\n" + << "The cumulative CPU time was " << timer_.elapsed()*numProcesses << " seconds.\n" << "We hope that you enjoyed simulating with us\n" << "and that you will choose us next time, too.\n"; } @@ -467,6 +472,7 @@ private: Scalar episodeLength_; std::string episodeDescription_; + Dune::Timer timer_; Scalar time_; Scalar endTime_; -- GitLab