How to use the command 'speed-test' (with examples)
The speed-test
command is a simple CLI tool that allows users to measure their internet connection speed and ping through the popular online service, Speedtest.net. It provides users with a quick and easy way to diagnose the performance of their internet connection by providing key metrics such as download and upload speeds, as well as ping times. This command can be particularly useful for those who are troubleshooting network issues, assessing ISP performance, or simply curious about the current state of their connection.
Use case 1: Test your internet connection and ping speed
Code:
speed-test
Motivation:
The primary reason to run the basic speed-test
command is that it offers an immediate assessment of your internet connection quality. This is advantageous for quickly checking whether your internet service is performing as promised by your ISP, especially when you suspect slow speeds or are trying to diagnose buffering issues during streaming or prolonged loading times on websites.
Explanation:
speed-test
: The commandspeed-test
without any additional arguments performs the standard internet speed test, providing the user with real-time feedback about the download and upload speeds as well as the latency (ping) of their current internet connection. This serves as a baseline measurement and can be a simple go-to diagnostic tool.
Example Output:
Ping: 20 ms
Download: 50.5 Mbps
Upload: 10.2 Mbps
Use case 2: Print the results as JSON
Code:
speed-test --json
Motivation:
Using the --json
option to print the results in JSON format is essential for users who need to incorporate the speed test data into scripts or automated systems. This is especially useful for data logging, comparison over time, or integration into system monitoring dashboards where JSON acts as a standard format that can be easily parsed and processed.
Explanation:
speed-test
: The command initiates the speed test.--json
: This argument changes the output format of the speed test results to JSON, a structured data format that can be utilized by various programming environments for further processing or storage.
Example Output:
{
"ping": 20,
"download": 50500000,
"upload": 10200000
}
Use case 3: Print the results in megabytes per second (MBps)
Code:
speed-test --bytes
Motivation:
The primary motivation for using the --bytes
option is when dealing with data transfer rates where understanding the results in terms of file sizes is more relevant. Many users find it easier to conceptualize results in megabytes rather than megabits, given that files are often measured in bytes, making it simpler to estimate download or upload times for large files.
Explanation:
speed-test
: The basic command to start the internet connection speed test.--bytes
: This argument modifies the output so that speeds are displayed in megabytes per second (MBps) instead of the default megabits per second (Mbps).
Example Output:
Ping: 20 ms
Download: 6.31 MBps
Upload: 1.26 MBps
Use case 4: Print more detailed information
Code:
speed-test --verbose
Motivation:
Using the --verbose
flag appeals to users who require an in-depth analysis of their internet connection metrics. This verbose output typically includes additional details such as the server used for testing, the IP address, ISP information, and more. This comprehensive report is beneficial for IT professionals or network engineers who may need to address specific diagnostic needs or detailed reporting.
Explanation:
speed-test
: Commences the speed test.--verbose
: This flag provides a more thorough report, often varying by providing additional technical details beyond the basic speed metrics, allowing users to understand better the conditions and configurations at play during the test.
Example Output:
Server: Speedtest Server - Location
ISP: Example ISP
IPv4: xxx.xxx.xxx.xxx
Ping: 20 ms
Download: 50.5 Mbps
Upload: 10.2 Mbps
Conclusion:
The speed-test
command is a versatile tool for gauging internet performance, offering multiple output formats to cater to varying user needs. Whether you’re looking for a quick check, need machine-readable data, want results in more intuitive units, or require comprehensive details, speed-test
provides an accessible way to measure your internet connection’s speed and reliability.