Add latency measurements to json outputs #204
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add latency measurements to json outputs
Hi! First of all, thank you for creating this project. I was looking for an official CLI for the cloudflare speedtest website but couldn't find anything. This is a lifesaver.
I'd love to include your project as a data source for Cloudflare in my project MySpeed, if that would be okay with you. I couldn't find any way to contact you here on GitHub so I thought I'd mention it in this PR here.
Motivation
I was looking for a way to parse the essential data for a speedtest (Download, Upload, Ping). I found that there is both a
json
andjson-pretty
output type but that didn't include the latency measurements I was hoping for.To actually retrieve everything I need, I would have to parse the latency out of the text with a regex, which is not an ideal solution for me.
Changes
This PR adds latency measurements to the
json
andjson-pretty
output. This also means that there will be a breaking change for the json output since I couldn't match the datatype of the latency onto theStatMeasurement
, so I created a new one.Outputs of the speed measurements will go in the
speed_measurements
array and latency will go in thelatency_measurements
array.Example
I've never worked with Rust before so if there are any improvements regarding the code quality or naming, please let me know and I will fix it asap.