Boost logo

Boost :

Subject: Re: [boost] [Boost.tracer] library request
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-01-20 03:44:51


Hi,

Boost.Chrono provide already this functionality with its new feature Stopwatch. See http://old.nabble.com/-chrono--v0.3--New-Stopwatch-Feature-tt27202338.html.

Stopwatch is a an generic feature that allows the user to trace all you trace and more expect your "Average T between calls".
stopclock<> provides a run time reporting package that can be invoked in a single line of code to report the usage of a Clock.
stopclock_accumulator<> associates an accumulator with a stopwatch, so we are able to retrieve any statistical feature Boost.Accumulator provides. For example: .

******** START OF FILE ********
#include <boost/stopwatches.h>
#include <cmath>

#define TRACE_LIFETIME \
  static boost::chrono::stopclock_accumulator<> acc(BOOST_CHRONO_ACCUMULATOR_FUNCTION_FORMAT); \
  boost::chrono::stopclock_accumulator<>::scoped_run _(acc);

int f1(long j)
{
  TRACE_LIFETIME;

  for ( long i = 0; i < j; ++i )
    std::sqrt( 123.456L ); // burn some time

  return 0;
}
int main()
{
  TRACE_LIFETIME;

  f1(100000);
  f1(200000);
  f1(300000);
  return 0;
}

******** END OF FILE ********
produce the output

int f1(long int) : 3 times, sum=0.031s, min=0.006s, max=0.013s, mean=0.010s
int main() : 1 times, sum=0.031s, min=0.031s, max=0.031s, mean=0.031s

I'm interesteed in seen your code, could you upload it somewhere?

Any comments on the Stopwatch part of the Chrono library is welcome.

Best,
Vicente

----- Original Message -----
From: "Andrew Chinkoff" <achinkoff_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, January 20, 2010 12:47 AM
Subject: [boost] [Boost.tracer] library request

>
> [Boost.tracer] library request is founded on a desire to
> trace some statistics about program execution.
>
> The sample program below demonstrates these statistics.
>
> Sample program file:
>
> ******** START OF FILE ********
> #include <tracer.h>
> void foo()
> {
> TRACE_LIFETIME;
> usleep(rand() % 100000);
> }
> int main()
> {
> TRACE_LIFETIME;
> for(int i = 0; i < 100; ++i)
> foo();
> }
> ******** END OF FILE ********
>
> Produced log file:
>
> ******** START OF FILE ********
> All the program time: 05265686 us (micro secs)
>
> TRACE POINT:
> Function: int main()
> Calls: 0000000001 times
> Average T between calls: 0000000000 us
> Average life T: 0005264459 us
> File: main.cpp
> Line: 00000009
>
> TRACE POINT:
> Function: void foo()
> Calls: 0000000100 times
> Average T between calls: 0000051665 us
> Average life T: 0000052606 us
> File: main.cpp
> Line: 00000004
> ******** END OF FILE ********
>
> Comment:
>
> TRACE_LIFETIME is a MACRO that traces some scope statistics, namely:
> "Function" - the function name where the scope is;
> "Calls" - number of entries into this scope;
> "Average T between calls" - average time period between "Calls";
> "Average life T" - average time spent in this scope.
>
> Conclusion:
>
> I think it is reasonable to introduce this trace functionality into
> (for example) boost::tracer namespace.
> I had wrote tracer.h and tracer.cpp source files and
> I wish Boost community to consider them.
>
> Thank You.
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk