
----- Original Message ----- From: "Gennadiy Rozental" <gennadiy.rozental@thomson.com> To: <boost@lists.boost.org> Sent: Friday, February 04, 2005 2:17 PM Subject: [boost] Re: Profiling Library suggestion
How is it better than what boost::timer provide?
Gennadiy
Hello, I was unaware of timer's existance, thanks for pointing it out. I had searched for "profiling", and "profiler". So I just took a look at: http://www.boost.org/libs/timer/timer.htm and I would humbly submit that perhaps what is lacking in progress_timer is a policy, and the ability to name profiles. I would like then to propose: struct profiler_default_policy { typedef boost::timer timer_t; static void on_profiled(const char* name, const timer_t& t) { double sec = t.elapsed(); cout << "time elapsed (msec) during profile " << name << " was " << sec / 1000; if (sec <= t.elapsed_min()) { cout << " *underflow* "; } if (sec >= t.elapsed_max()) cout << " *overflow* "; } cout << endl; } }; struct interesting_profiler_policy { typedef boost::timer timer_t; static map<string, double> profiles; static void on_profiled(const char* name, const timer_t& t) { double sec = t.elapsed(); profiles[name] = sec; } }; template<typename policy_t> class basic_profiler { public: profiler(char const* s = "") : name(s) { }; ~profiler() { policy_t::on_profiled(name, timer); }; private: char const* name; typename policy_t::timer_t timer; }; typedef basic_profiler<default_profiler_policy> profiler; This would have an advantage over progress_timer that library users may modify the behaviour of the profiler, without rewriting the class. It can also be used with more high-performance timers if the user has one at their disposal. Any comments or suggestions? Christopher Diggins Object Oriented Template Library (OOTL) http://www.ootl.org