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 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

Hello, ----- Original Message ----- From: "Justinas V. Daugmaudis" <jvd@tja.lt> To: <boost@lists.boost.org> 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 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 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. Kind regards, Philip Bennefall

I will have a look at this extension. Meanwhile, I have found that typically people implement the speedometers somewhat incorrectly (they tend to trivialize that). Even my suggested version could be discussed, because the current implementation 'jumps' from one time window to another. It is probable, that the continually 'sliding' version would be much better; at least it would be more stable in that regard that the speed would not fluctuate each time, when a new measuring period starts. Le 19 février 2012 01:13, Julien Nitard <julien.nitard@m4tp.org> a écrit :
Hi
[...]
Is there any interest in such a utility class?
Yes there is ! You may to have a look a .Net "reactive extensions" (Rx) that allows event processing in a somewhat similar fashion.
Julien
-- Kind regards, Justinas V. Daugmaudis
participants (3)
-
Julien Nitard
-
Justinas V. Daugmaudis
-
Philip Bennefall