My understanding of how those "speed tests" work, is that they have a large file which they download to the client, and measure how long it took.
It wouldn't be too hard to work that one out.....
When they click the submit button to test, cookie the time they clicked it. Then, when the page is finished loading, look at the cookie, see how many seconds it took, divide that into the size of the file.....
Make sure you turn off the cache, so that it downloads the "big file" every time it runs.
Just my 2¢
"In order to start solving a problem, one must first identify its owner." --Me
--Greg