
christopher diggins wrote:
I was searching around boost for mention of a profiling library. A fellow by the name of Carl Daniels posted something about an invasive profiling library. I was wondering in anyone knows what happened to that project? Profiling seems lacking at Boost, is anyone else interested in such a thing?
Would a trivial policy driven RAII type be sufficient to garner interest as a mini-library?
e.g.
struct ProfilerDefaultPolicy { OnElapsed(int msec) { cout << "time elapsed (msec): " << msec << endl; } };
template<typename Policy_T = ProfilerDefaultPolicy> class Profiler { public: Profiler() { mnStart = GetTickCount(); }; ~Profiler() { Policy_T::OnElapsed(GetMSecElapsed()); }; int GetMSecElapsed() { return GetTickCount() - mnStart; }; int GetTickCount() { return int(double(clock()) * 1000 / CLOCKS_PER_SEC); }; private: int mnStart; };
usage:
void MyRoutine() { Profiler<> p; // do stuff }
How about: typedef profiled< MyClass, Interface, Profiler<> > > MyProfiledClass; ? This would be a good application of aspect-oriented programming. Jonathan