openspeedtest / Speed-Test

SpeedTest by OpenSpeedTestâ„¢ is a Free and Open-Source HTML5 Network Performance Estimation Tool Written in Vanilla Javascript and only uses built-in Web APIs like XMLHttpRequest (XHR), HTML, CSS, JS, & SVG. No Third-Party frameworks or libraries are Required. Started in 2011 and moved to OpenSpeedTest.com dedicated Project/Domain Name in 2013.
https://openspeedtest.com
MIT License
2.28k stars 221 forks source link

Feature Request: Ping Result with Decimal Place (sub milliseconds) #141

Open zR-JB opened 4 months ago

zR-JB commented 4 months ago

Or is this not possible because of the accuracy of: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now

used in https://github.com/openspeedtest/Docker-Image/blob/main/files/www/assets/js/app-2.5.4.js#L1319 ? ?

zR-JB commented 4 months ago

Maybe it is possible, they claim sub millisecond accuracy: https://developer.mozilla.org/en-US/docs/Web/API/Performance_API/High_precision_timing

zR-JB commented 4 months ago

What is the reason, that Math.floor() ist used there ?

openspeedtest commented 4 months ago

@zR-JB Check https://github.com/openspeedtest/Docker-Image/blob/main/files/www/assets/js/app-2.5.4.js#L1337C13-L1340C21 I did that because of Safari. Safari will return zero if we go for sub-millisecond accuracy.

zR-JB commented 4 months ago

How much work would an extra flag be, to enable this for the users that want it ?

openspeedtest commented 4 months ago

@zR-JB It's easy. If necessary, I can add a flag in the next version, and I am planning to do that in the coming weeks. But who cares about sub-millisecond accuracy? What is the real-world application?

zR-JB commented 4 months ago

Many use openspeedtest inside their home network.

For me e.g. I always get 1ms reading at home, but 0,5 ms and 1,95 is a huge difference when debugging Wi-Fi or even LAN.

And with my new Fiber line I also get sub-millisecond latency to some other public services, so at least the first decimal place matters. I think 0,2 ms latency to the first hop is pretty much standard nowadays.

Or let's say I introduce a new Router or Layer 3 Switch inside my home network (between two subnets or so) and want to measure the impact on real world latency.

openspeedtest commented 4 months ago

@zR-JB Thank you for pointing out this issue. I will address it very soon.

Weegley commented 3 months ago

According to Mozilla You will not get precision better than 1 ms in Firefox anyway... Chrome and Edge seem to give 0.1ms precision ping results.

zR-JB commented 3 months ago

According to Mozilla You will not get precision better than 1 ms in Firefox anyway... Chrome and Edge seem to give 0.1ms precision ping results.

Yeah, I did some further testing and got 0.1ms accuracy only with chromium based browsers!

vishnunuk commented 3 months ago

@zR-JB Yes FF Array(9) [ 1, 0, 1, 0, 0, 1, 0, 0, 1 ]

Chrome (9) [1.5, 1, 0.5999999940395355, 0.3999999910593033, 0.3999999910593033, 0.6000000089406967, 0.9000000059604645, 0.5999999940395355, 0.5999999940395355]

Safari [0.9999999999999858, 1, 1, 1, 0.9999999999999858, 1, 1, 1, 1] (9)

I think it's better to report what the browser returns, but you'll see 0 on Firefox and 0.1 on Chrome and Safari.

zR-JB commented 3 months ago

Yes would say so, too. If the flag is set, report the raw browser response. Maybe in the future something changes with the browser's too, so who knows. Might be even more helpful in the future!