Open notpushkin opened 1 year ago
Oh hi, I am that someone :) It's more for a personal project of mine, but I'd be happy to contribute back if there is interest. Unfortunately, according to #17 a CLI is out of reach (for now) due to nodejs being incompatible with this library.
https://github.com/nodejs/undici/pull/2481 was just merged, which adds the PerformanceTiming API entries needed for this library. So we're getting closer to getting this working in node.
That's great @ToshB! Any idea of how long it will take of the release of Node with the mentioned features?
Looks like it was merged into Node two days ago, https://github.com/nodejs/node/commit/05f81721889571f615e36bf70fac759f4d118513, so it shouldn't be too long.
And works like a charm too with the nightly build of node 22:
❯ node
Welcome to Node.js v22.0.0-nightly202401090090c10782.
Type ".help" for more information.
> const {default: Speedtest } = await import('@cloudflare/speedtest');
undefined
> (node:50124) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> new Speedtest().onFinish = results => console.log(results.getSummary());
[Function (anonymous)]
> {
download: 225662382.7740472,
upload: 37244214.56244167,
latency: 17.63653700000069,
jitter: 1.0500115789465496,
downLoadedLatency: 27.033390500009148,
downLoadedJitter: 16.086571000001342,
upLoadedLatency: 42.60906900000435,
upLoadedJitter: 70.95178205555446
}
I was gonna try and run this in my golang based speedtest background task as some sort of abomination where I'd use it in chrome via devtools and get the results that way, but I was too busy lately and my current speedtest provider was ok enough. But now I will definitely rebuild this with the cloudflare speedtest. Thanks @ToshB for your effort!
I tried it too with v22 nightly. Very smooth! Thanks @ToshB!
Very cool! I am curious to see if the Node speedtest results are comparable to the browser results. I would assume the fetch-implementations in browsers are tuned to the extreme..
Note that there are some speedtest engines which is still not compatible with Node. Specifically the packetloss tests, which requires WebRTC. I was not able to find a working Node implementation of RTCPeerConnection.
Very cool! I am curious to see if the Node speedtest results are comparable to the browser results. I would assume the fetch-implementations in browsers are tuned to the extreme..
I've tried a browser based speed test in chromium on a raspberrypi where the bandwidth was severely limited for reasons I don't know. The ookla speed test CLI works, but I'm a bit cautious as it collects so much data from the client.
This node based speed test seems to be a better alternative.
Thanks for this project! Are you also planning to add a CLI interface? Someone on HN has already started an implementation, but perhaps you could collab and release it as part of this package.