Changeset 9a9f847 for ThirdParty/CodePatterns
- Timestamp:
- Jun 19, 2017, 8:23:19 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChemicalSpaceEvaluator, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
- Children:
- 61003d, 788dce, be848d
- Parents:
- 51a013
- git-author:
- Frederik Heber <frederik.heber@…> (06/19/17 08:23:15)
- git-committer:
- Frederik Heber <frederik.heber@…> (06/19/17 08:23:19)
- Location:
- ThirdParty/CodePatterns/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ThirdParty/CodePatterns/src/CodePatterns/Chronos.hpp
r51a013 r9a9f847 17 17 #include <map> 18 18 #include <string> 19 20 #include <boost/thread/recursive_mutex.hpp> 19 21 20 22 #include "CodePatterns/Singleton.hpp" … … 131 133 #endif 132 134 #endif 135 136 //!> mutex for keeping chronos timekeeping atomic 137 mutable boost::recursive_mutex ChronosMutex; 133 138 }; 134 139 -
ThirdParty/CodePatterns/src/Helpers/Chronos.cpp
r51a013 r9a9f847 22 22 #include <iostream> 23 23 24 #include <boost/thread/locks.hpp> 25 24 26 #ifdef HAVE_UNISTD_H 25 27 #include <unistd.h> … … 32 34 # include <time.h> 33 35 #endif 34 35 36 36 37 #include "CodePatterns/Chronos.hpp" … … 69 70 double Chronos::getTime(const std::string &_name) const 70 71 { 72 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 71 73 // only those functions have a time that have run already 72 74 if (AccountedTime.count(_name) != 0) { … … 82 84 void Chronos::resetTime(const std::string &_name) 83 85 { 86 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 84 87 // set accounted time to zero 85 88 if (AccountedTime.count(_name) != 0) { … … 93 96 void Chronos::startTiming(const std::string &_name) 94 97 { 98 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 95 99 // start time keeping 96 100 if ((RecursionMap.count(_name) == 0) || (RecursionMap[_name] == 0)) { … … 106 110 const sec_ncsec_t &_time2) 107 111 { 108 112 double currenttime = 0.; 109 113 if (_time1.second < _time2.second) 110 114 currenttime = (_time1.first - _time2.first - 1) … … 118 122 double Chronos::getCurrentTime() const 119 123 { 124 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 120 125 #ifdef HAVE_TIME_H 121 126 // clock_gettime gives nanoseconds accuracy … … 158 163 void Chronos::endTiming(const std::string &_name) 159 164 { 165 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 160 166 // check whether we are the topmost function, return if not 161 167 if (--RecursionMap[_name] != 0) … … 183 189 double Chronos::SumUpTotalTime() const 184 190 { 191 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 185 192 double sum = 0.; 186 193 for (TimekeepingMap::const_iterator iter = AccountedTime.begin(); … … 194 201 size_t Chronos::SumUpTotalFunctions() const 195 202 { 203 boost::recursive_mutex::scoped_lock lock(ChronosMutex); 196 204 return AccountedTime.size(); 197 205 } … … 199 207 std::ostream& operator<<(std::ostream &ost, const Chronos &_time) 200 208 { 209 boost::recursive_mutex::scoped_lock lock(_time.ChronosMutex); 201 210 ost << "List of functions present:" << std::endl; 202 211 for (Chronos::TimekeepingMap::const_iterator iter = _time.AccountedTime.begin();
Note:
See TracChangeset
for help on using the changeset viewer.