Boost logo

Boost :

Subject: [boost] Discrete speedometer
From: Justinas V. Daugmaudis (jvd_at_[hidden])
Date: 2012-02-18 08:24:04


Currently Boost has date_time library and it especially has time_duration.
However, what I find lacking is some means to track the number of discrete
events that happen during some specified time_duration window. Something
modelled after boost::progress.

For example, consider that we are interested in how many files have been
copied per five minutes, or how many packets have been received per ten
minutes, etc. Obviously, the bigger the time window, the more stable the
speedometer.

I would like to do something like this:
discrete_speedometer ds(posix_time::minutes(5)); // Tracks the events using
the 5 minute window

for( ... ) // Some inner loop
{
  ds += number_of_events;
}

>From time to time I can do this:
double events_per_second =
speed_per_duration<double>(ds, posix_time::seconds(1));

or even more succinctly
double events_per_second = speed_per_second(ds);

I have implemented such a feature, and the code is here:
http://people.binf.ku.dk/~jvd/discrete_speedometer.hpp

Is there any interest in such a utility class?

Regards,
Justinas


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