You may be able to use the open source JAMon api to do this (in the interest of disclosure i am the author). It aggregates statistics in realtime, is fast and lightweight. The current version was mainly created to track performance, but the next version (i am working on it as we speak) will aggregate stats for numbers besides time (ms.).
Here is the way you could use the current version of JAMon:
The next version will allow you to pass a value in and teh values will be aggregated. Sort of like a database, except individual data points are thrown out and only aggregates such as average, min, max, total, standard deviation and a few more are kept.
Here are a few examples
Here is a link to the code I am working on that will eventually make it to production. It is by no means done yet.
http://cvs.sourceforge.net/viewcvs.py/jamonapi/jamonapi/src/playground/#dirlist Also, this code was my first start and will do much of what you want in one class. You can use this if you want. Look at the main method to see how it works. This class can be run by itself.
http://cvs.sourceforge.net/viewcvs.py/jamonapi/jamonapi/src/playground/TempMon.java?rev=1.1&view=markup To see a demo of JAMon go to the 'live demo' at the
www.fdsapi.com link below and then click on jamon stats in the app and you will see how it works.
[ December 20, 2005: Message edited by: steve souza ]