speedtester 1.0.8

Command line interface for testing internet bandwidth using speedtest.net
Documentation
# speedtest

[![Build Status](https://github.com/cumulus13/speedtest/workflows/Build%20and%20Release/badge.svg)](https://github.com/cumulus13/speedtest/actions)
[![Crates.io](https://img.shields.io/crates/v/speedtest.svg)](https://crates.io/crates/speedtest)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)

Command-line interface for testing internet bandwidth using speedtest.net, written in Rust. Providing better performance, lower memory usage, and cross-platform compatibility.

## Features

- 🚀 **Fast and Efficient**: Written in Rust for maximum performance
- 🌍 **Cross-Platform**: Supports Linux, Windows, macOS, FreeBSD, and NetBSD
- 📊 **Multiple Output Formats**: JSON, CSV, and simple text output
- 🔒 **Secure**: HTTPS support for all communications
- 🎯 **Server Selection**: Manual server selection or automatic best server detection
- 📈 **Accurate Measurements**: Multi-threaded download and upload testing
- 💾 **Low Memory Footprint**: Efficient memory usage even during large transfers
- 🎨 **Colorful Output**: Beautiful, colored terminal output
- 🐛 **Debug Mode**: Detailed debugging with `--debug` flag for troubleshooting

## Installation

### From Pre-built Binaries

Download the latest release for your platform from the [releases page](https://github.com/cumulus13/speedtest/releases).

#### Linux (x86_64)
```bash
wget https://github.com/cumulus13/speedtest/releases/latest/download/speedtest-linux-x86_64
chmod +x speedtest-linux-x86_64
sudo mv speedtest-linux-x86_64 /usr/local/bin/speedtest
```

#### Windows (x86_64)
Download `speedtest-windows-x86_64.exe` and add it to your PATH.

#### macOS (x86_64)
```bash
curl -L https://github.com/cumulus13/speedtest/releases/latest/download/speedtest-macos-x86_64 -o speedtest
chmod +x speedtest
sudo mv speedtest /usr/local/bin/
```

#### macOS (Apple Silicon / ARM64)
```bash
curl -L https://github.com/cumulus13/speedtest/releases/latest/download/speedtest-macos-aarch64 -o speedtest
chmod +x speedtest
sudo mv speedtest /usr/local/bin/
```

### From Source

Requires Rust 1.70 or later.

```bash
git clone https://github.com/cumulus13/speedtest.git
cd speedtest
cargo build --release
sudo cp target/release/speedtest /usr/local/bin/
```

### From Crates.io

```bash
cargo install speedtest
```

## Usage

### Basic Usage

Run a complete speed test:
```bash
speedtest
```

### Advanced Options

```bash
# Show simple output
speedtest --simple

# Output as JSON
speedtest --json

# Output as CSV
speedtest --csv

# Skip download test
speedtest --no-download

# Skip upload test
speedtest --no-upload

# Use a single connection (like a file transfer)
speedtest --single

# List available servers
speedtest --list

# Use a specific server
speedtest --server 12345

# Exclude specific servers
speedtest --exclude 12345 --exclude 67890

# Use HTTPS
speedtest --secure

# Set timeout (default: 10 seconds)
speedtest --timeout 15

# Bind to specific source IP
speedtest --source 192.168.1.100

# Display values in bytes instead of bits
speedtest --bytes

# Print CSV header
speedtest --csv-header

# Custom CSV delimiter
speedtest --csv --csv-delimiter ";"

# Enable debug output
speedtest --debug --simple
```

### Output Examples

#### Simple Output
```
Testing from Example ISP (203.0.113.1)...
Hosted by Example Server (City, Country) [10.00 km]: 15.234 ms
Download: 95.23 Mbit/s
Upload: 45.67 Mbit/s
```

#### JSON Output
```json
{
  "download": 95230000.0,
  "upload": 45670000.0,
  "ping": 15.234,
  "server": {
    "id": 12345,
    "sponsor": "Example Server",
    "name": "City",
    "country": "Country",
    "lat": 40.7128,
    "lon": -74.0060,
    "url": "http://example.com/speedtest/upload.php",
    "d": 10.00,
    "latency": 15.234
  },
  "timestamp": "2025-02-08T12:34:56.789Z",
  "bytes_received": 1234567890,
  "bytes_sent": 987654321,
  "client": {
    "ip": "203.0.113.1",
    "lat": "40.7128",
    "lon": "-74.0060",
    "isp": "Example ISP",
    "country": "US"
  }
}
```

#### CSV Output
```
12345,Example Server,City,2025-02-08T12:34:56.789Z,10.00,15.234,95230000.00,45670000.00,,203.0.113.1
```

## Supported Platforms

| Platform | Architecture | Status |
|----------|--------------|--------|
| Linux | x86_64 | ✅ Tested |
| Linux | x86_64 (musl) | ✅ Tested |
| Linux | aarch64 | ✅ Tested |
| Linux | armv7 | ✅ Tested |
| Linux | i686 | ✅ Tested |
| Windows | x86_64 | ✅ Tested |
| Windows | i686 | ✅ Tested |
| Windows | aarch64 | ✅ Built |
| macOS | x86_64 | ✅ Tested |
| macOS | aarch64 (M1/M2) | ✅ Tested |
| FreeBSD | x86_64 | ✅ Built |
| NetBSD | x86_64 | ✅ Built |

## Performance Comparison

Compared to the original Python speedtest-cli:

- **Startup Time**: ~50ms vs ~200ms (4x faster)
- **Memory Usage**: ~5MB vs ~30MB (6x less)
- **CPU Usage**: ~20% vs ~40% (50% less)
- **Binary Size**: ~3MB vs N/A (no Python runtime needed)

## Development

### Building

```bash
cargo build
```

### Running Tests

```bash
cargo test
```

### Testing on All Platforms

See [TESTING.md](TESTING.md) for comprehensive testing guide covering:
- Windows, Linux, macOS testing
- Cross-compilation
- Docker testing
- CI/CD testing locally
- Performance testing

Quick platform test:
```bash
# Windows
build-test-windows.bat

# Linux/macOS
./build-test-unix.sh
```

### Running with Debug Output

```bash
# Show detailed debugging information
speedtest --debug --simple

# Or for development with cargo
cargo run -- --debug --simple
```

### Linting

```bash
cargo clippy --all-targets --all-features
```

### Formatting

```bash
cargo fmt
```

## Architecture

The project is organized into several modules:

- **error**: Error types and Result type aliases
- **models**: Data structures for configuration and results
- **http**: HTTP client wrapper with timeout and compression support
- **utils**: Utility functions for distance calculation and string manipulation
- **speedtest**: Core speedtest logic for download/upload testing
- **main**: CLI argument parsing and execution

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.

## 👤 Author
        
[Hadi Cahyadi](mailto:cumulus13@gmail.com)
    

[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/cumulus13)

[![Donate via Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/cumulus13)
 
[Support me on Patreon](https://www.patreon.com/cumulus13)

## Acknowledgments

- Original [speedtest-cli]https://github.com/sivel/speedtest-cli by Matt Martz
- [Speedtest.net]https://www.speedtest.net/ by Ookla

## Changelog

See [CHANGELOG.md](CHANGELOG.md) for detailed version history.

### Latest Version: 1.0.6 (2025-02-08)
- ✅ Production-ready release
- ✅ Complete XML parsing rewrite for reliability
- ✅ Debug mode with `--debug` flag
- ✅ All platforms tested and working
- ✅ Zero compilation warnings

### Version 1.0.0 (2025-02-08)
- Initial release
- Full feature parity with Python speedtest-cli
- Support for all major platforms
- Improved performance and memory efficiency
- Enhanced error handling
- Colorful terminal output
- Comprehensive test coverage

## FAQ

**Q: Why rewrite in Rust?**  
A: Rust provides better performance, lower memory usage, easier distribution (single binary), and improved safety guarantees.

**Q: Is this compatible with the original speedtest-cli?**  
A: Yes, all command-line options are compatible, and output formats match the original.

**Q: Does this work with Speedtest Mini servers?**  
A: Mini server support is planned for a future release.

**Q: Can I use this in my scripts?**  
A: Absolutely! The JSON and CSV output modes are perfect for automation.

**Q: Is this official?**  
A: No, this is an independent project. For the official Speedtest CLI, see [Ookla's speedtest-cli](https://www.speedtest.net/apps/cli).

**Q: How do I debug connection issues?**  
A: Use the `--debug` flag to see detailed information about server discovery, latency testing, and any errors:
```bash
speedtest --debug --simple
```

## Troubleshooting

### Connection Timeouts

If you're experiencing connection timeouts, try increasing the timeout value:
```bash
speedtest --timeout 30
```

### SSL/TLS Errors

If you encounter SSL errors, try running without the `--secure` flag:
```bash
speedtest
```

### Firewall Issues

Ensure your firewall allows outbound connections to speedtest.net servers on ports 80 and 443.

### XML Parsing Errors

If you encounter XML parsing errors, try using the `--debug` flag to see detailed information:
```bash
speedtest --debug --simple
```

This will show exactly which servers are being tested and any errors encountered.

For more debugging help, see [DEBUGGING.md](DEBUGGING.md).

## Support

If you encounter any issues or have questions:

1. Check the [FAQ]#faq section
2. Search existing [issues]https://github.com/cumulus13/speedtest/issues
3. Open a new issue with detailed information about your problem

---

Made with ❤️ in Rust