
From: christopher diggins <cdiggins@videotron.ca>
From: "Gennadiy Rozental" <gennadiy.rozental@thomson.com>
{ profiler p; // some code p.stop();
I'd expect that to be called "pause" not "stop." The latter sounds more like it would report and reset the timer so that a subsequent call to start() would be starting from zero.
// some other code we do not want to profile p.resume();
"continue" might be a better name.
// continue profiling p.stop()
Not needed unless there were following code you didn't want to time, right?
} // here we print report
I expect report to be print only once
stop() and resume() are not part of the design.
He's suggesting that they should be.
You would write the above code as:
{ { basic_profiler<collecting_policy> p("profile1"); // some code } // some other code we do not want to profile { basic_profiler<collecting_policy> p("profile1"); // continue profiling } collecting_policy::generate_report(); } }
Maybe you would, but I think that makes the profiler class too painful. Gennadiy's version is much simpler to read and write, and it doesn't assume that collecting_policy references a common object that will collect statistics for all basic_profilers that mention "profile1." The latter means that a name doesn't need to be repeated, which could be a source of errors, and it simplifies the profiler class' implementation. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;