Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI #26

Open
notpushkin opened this issue Aug 10, 2023 · 8 comments
Open

CLI #26

notpushkin opened this issue Aug 10, 2023 · 8 comments

Comments

@notpushkin
Copy link

notpushkin commented Aug 10, 2023

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.

@bmo-at
Copy link

bmo-at commented Aug 11, 2023

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.

@ToshB
Copy link

ToshB commented Dec 20, 2023

nodejs/undici#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.

@hakonk
Copy link

hakonk commented Jan 9, 2024

That's great @ToshB! Any idea of how long it will take of the release of Node with the mentioned features?

@ToshB
Copy link

ToshB commented Jan 9, 2024

Looks like it was merged into Node two days ago, nodejs/node@05f8172, so it shouldn't be too long.

@bmo-at
Copy link

bmo-at commented Jan 9, 2024

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!

@hakonk
Copy link

hakonk commented Jan 11, 2024

I tried it too with v22 nightly. Very smooth! Thanks @ToshB!

@ToshB
Copy link

ToshB commented Jan 11, 2024

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.

@hakonk
Copy link

hakonk commented Jan 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants