Subject: Re: [boost] Discrete speedometer
From: Philip Bennefall (philip_at_[hidden])
Date: 2012-02-18 17:48:37
----- Original Message -----
From: "Justinas V. Daugmaudis" <jvd_at_[hidden]>
Sent: Saturday, February 18, 2012 2:24 PM
Subject: [boost] Discrete speedometer
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
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 =
or even more succinctly
double events_per_second = speed_per_second(ds);
I have implemented such a feature, and the code is here:
Is there any interest in such a utility class?
Personally I think this would be nice. It's simple, but not trivial enough
to make it unsuitable for Boost in my opinion. I'd certainly use it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk