![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 #ifndef __STOPWATCH_H 00002 #define __STOPWATCH_H 00003 00004 #define NOMINMAX 00005 00006 #include <boost/accumulators/accumulators.hpp> 00007 #include <boost/accumulators/statistics.hpp> 00008 #include <boost/accumulators/statistics/stats.hpp> 00009 #include <boost/accumulators/statistics/count.hpp> 00010 #include <boost/accumulators/statistics/min.hpp> 00011 #include <boost/accumulators/statistics/max.hpp> 00012 #include <boost/accumulators/statistics/sum.hpp> 00013 00014 #include "tick_count.h" 00015 00016 #include <map> 00017 #include <string> 00018 00019 #include "ManagedDictionary.h" 00020 #include "Timer.h" 00021 00022 namespace Support 00023 { 00024 //typedef the complex templates used by Stopwatch for clarity 00025 typedef boost::accumulators::features<boost::accumulators::tag::mean, 00026 boost::accumulators::tag::count, 00027 boost::accumulators::tag::min, 00028 boost::accumulators::tag::max, 00029 boost::accumulators::tag::sum> 00030 StopwatchStats; 00031 00032 typedef boost::accumulators::accumulator_set<double, StopwatchStats> StopwatchAccumulator; 00033 00048 class Stopwatch 00049 { 00050 protected: 00051 tbb::tick_count _timeAtConstruction; 00052 std::string _name; 00053 static ManagedDictionary<std::string, StopwatchAccumulator> _Accumulators; 00054 static boost::mutex _AccumulatorsMutex; 00055 00056 static void AccumulateTime(const std::string& name, double timeElapsed); 00057 00058 public: 00059 00060 static void PrintAccumulatedTimes(); 00061 00062 INLINE static void PrintAccumulatedTimesConditional() 00063 { 00064 #ifdef PERF_CLOCKS 00065 Stopwatch::PrintAccumulatedTimes(); 00066 #endif 00067 } 00068 00069 Stopwatch(const std::string& name); 00070 ~Stopwatch(); 00071 }; 00072 } 00073 00074 #endif
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.