
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