RE: [boost] Profiler Library Proposal

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Martin Slater Sent: Saturday, February 05, 2005 10:30 PM To: boost@lists.boost.org Subject: Re: [boost] Profiler Library Proposal
christopher diggins wrote:
I have posted preliminary documentation and source code for a
proposal
for the boost profiler library at http://www.cdiggins.com/profiler/ . The code has been successfully compiled on Visual C++ 7.1 but not tested yet.
There have been some updates to the code as a result of the suggestions made so far. Any further comments are appreciated.
Being able to generate a heirarchicle recording / output would be very useful (the profiler we use at work does this) so you can drill down into code areas that are running slow.
cheers [Brian Braatz] Sharing some experiences in relation to where this thread looks like it may go :)
I am not proposing a library, just sharing with you a library I wrote and what the results were of building it. About a year ago, I played around with some similar concepts. I fundamentally wanted to "see what it would look like" if I could converge * Design By contract, * hierarchical logging * profiling Both by function and by cross cut concepts from a set of functions AND the operations IN those functions * reverse time debugging- I.e. you can go back in time and see how the call stack got you to where the error occurred. In addition to the previous call stacks that are now "gone". * Thread specific data tracking burned into the design By building the library, I got all of the above working. However many questions remained for me as to if the syntax required was "too much". This is still an open question in my mind in that I have not personally decided either way. As you will see the "requirements" for a simple function are quite verbose. What I built: Simple syntax for both profiling and for logging of the "context" of a concept. Ability to grab the callstack of "where" an error occurred and what the code was doing when it hit an error. Ability to put the local variables and the parameters into a call stack Ability to plug in profiling in such a way as to view a cross\cut of the performance of a set of operations Also time profiling was done on EVERYTHING- so with a fancy XSLT modifer, you can cross cut and get whatever kind of "executive level analysis" you want on the sheer volumne of data you have Basically, to the application coders, what this looks like is an "Eiffel" style programming model in C++, with the behind the scenes advantage of Profiling Call stack tracing Heirarchcal logging- With context concepts embedded in the log so you can go back later and look at a "slice" of the performance of something. I even built a debugger that let me look at the xml files and do this. App Code Requirements: The application code must do the following: Have a Root object Get a context object from root Pass the context object into each function with the name ctx This is for both thread reasons and the Use a Eiffel style syntax in the functions What this looks like in app code (sample code below actually works) void MyFunction3(Context ctx,int i,Object *p) { Function ( MyClass, MyFunction3, "Function Used for rotation" ); Parameters Param (i,"Integer for how many times to loop" ); Param (p,"Object to do something with" ); Locals int w = 0; Local(w,"Value for the weather"); int x = 0; Local(x,"Drag Coefficient"); Pre Execute comments << "Func3 is reobooting windows 95" << endl; ctx.SetError(std::string("DATABASE IS MISSING"),FLUID); Post EndFunc } void MyFunction2(Context ctx,int i,Object *p) { Function ( MyClass, MyFunction2, "Function Used for calculation" ); Parameters Param (i,"Integer for how many times to loop" ); Param (p,"Object to do something with" ); Locals int w = 0; Local(w,"Value for the weather"); int x = 0; Local(x,"Drag Coefficient"); Pre Execute comments << "Searching for weapons of mass destruction" << endl; MyFunction3(ctx,i,p); Post EndFunc } void MyFunction1(Context ctx,int i,Object *p) { Function ( MyClass, MyFunction1, "some other Function Used for calculation" ); Parameters Param(i,"Integer for counting") ; Param(p,"Object to destroy" ); Locals int w = 0; Local(w, "Value for the weather"); int x = 0; Local(x, "Drag Coefficient"); Operation (opAddToVector, "Add passed string "); Operation (opFindAllElements, "Find all elements "); Pre ctx.Check( i == 1,"i Must be greater than one ",FLUID); ctx.Check( Valid(p) || IsNull(p) , "p must be a valid object or null", FLUID); Execute { Scope (opAddToVector); comments << "Adding to vector" << endl; { Scope (opFindAllElements); Comments << "Finding all elements" << endl; MyFunction2(ctx,i,p); } } Post EndFunc }
participants (1)
-
Brian Braatz