showwin/speedtest-go

It's confusing that speedtest.New() uses the same GlobalDataManager

Opened this issue · 3 comments

eric commented

I assumed that each instance of the Speedtest object would have its own state, but it turned out it shared the GlobalDataManager which needed to be reset between runs to be able to give accurate results.

Hi, @eric. You are right. we fixed it and cache records of the last ten tests. reset is still needed.

eric commented

Originally I did not have a Reset() when the test was done (it still is unintuitive to me why I would need a Reset() when I am creating a new object each time) and the numbers I was getting on the second run were 2x the actual numbers. I assumed that speedtest.New() created a new session, but maybe introducing some sort of a session object for each test run would be a simpler way to understand from someone coming to the project for the first time.

eric commented

Reading through #155 and the examples, I now see that with the change, if I were to throw away the Speedtest object after each run and I am only testing one host, it is not required that I call Reset().