Skip to content

Repository files navigation

Cloudflare Speed Test Result (CSV file) Analyzer

A Python tool for analyzing Cloudflare speed test results stored in CSV format. This modular analyzer extracts and processes download speed data for 10MB tests, converting from bits per second (bps) to megabits per second (Mbps) for easy interpretation.

Features

  • 📊 Analyze Cloudflare Speed Test CSV Files: Process speed test results from Cloudflare's speed testing tool
  • 🎯 10MB Download Focus: Specifically extracts and analyzes 10MB (10,000,000 bytes) download test data
  • 📈 Speed Conversion: Automatically converts from bps to Mbps for readable results
  • 🔧 Modular Design: Reusable SpeedAnalyzer class for flexible usage
  • 📁 Batch Processing: Analyze single files or multiple files at once
  • 🛡️ Error Handling: Graceful handling of missing files and invalid data
  • 📋 Detailed Reports: Shows individual test speeds, averages, and custom statistics

Installation

  1. Clone or download this repository
  2. Ensure Python 3.6+ is installed on your system
  3. No external dependencies required - uses only Python standard library
git clone <repository-url>
cd SpeedTest_Analyzer

Project Structure

SpeedTest_Analyzer/
├── speed_analyzer.py          # Main SpeedAnalyzer class
├── analyze_all_files.py       # Batch processing script
├── example_usage.py           # Usage examples
├── README.md                  # This file
└── test_speed_data/           # Directory for CSV files
    ├── test_speed_1.csv
    ├── test_speed_2.csv
    └── ...

Usage

1. Basic Single File Analysis

from speed_analyzer import SpeedAnalyzer

analyzer = SpeedAnalyzer()
results = analyzer.analyze_single_file("test_speed_data/test_speed_1.csv")
analyzer.display_results(results)

Output:

==================================================
File: test_speed_1
==================================================
Number of 10MB download tests: 6
Download speeds (Mbps):
  Test 1: 21.90 Mbps
  Test 2: 19.38 Mbps
  Test 3: 15.40 Mbps
  Test 4: 11.63 Mbps
  Test 5: 18.39 Mbps
  Test 6: 19.01 Mbps

Average speed: 17.62 Mbps

2. Analyze Multiple Specific Files

from speed_analyzer import SpeedAnalyzer

analyzer = SpeedAnalyzer()
files_to_analyze = [
    "test_speed_data/test_speed_1.csv",
    "test_speed_data/test_speed_2.csv",
    "test_speed_data/test_speed_3.csv"
]
analyzer.analyze_multiple_files(files_to_analyze)

3. Batch Process All CSV Files

# Run the batch processing script
python analyze_all_files.py

4. Custom Analysis

from speed_analyzer import SpeedAnalyzer

analyzer = SpeedAnalyzer()
results = analyzer.analyze_single_file("test_speed_data/test_speed_1.csv")

if results:
    speeds = results['speeds_mbps']
    min_speed = min(speeds)
    max_speed = max(speeds)
    speed_range = max_speed - min_speed
    
    print(f"Minimum speed: {min_speed:.2f} Mbps")
    print(f"Maximum speed: {max_speed:.2f} Mbps")
    print(f"Speed range: {speed_range:.2f} Mbps")

CSV File Format

The analyzer expects CSV files with the following structure from Cloudflare speed tests:

time,direction,bytes,latency,bps,duration,serverTime,responseSize,loadedLatencies
1752605755529,download,10000000,30.500023,21899266.259138077,3653.2000229284745,98.999977,10000300,69.09999402384186...
1752605759716,download,10000000,33.999954,19383713.539181642,4127.2999540715255,52.000046,10000300,26.000109000000002...

Key Fields:

  • direction: Must be "download" for analysis
  • bytes: Must be exactly 10,000,000 (10MB) for extraction
  • bps: Download speed in bits per second (converted to Mbps)

Scripts Overview

speed_analyzer.py

The core module containing the SpeedAnalyzer class with methods:

  • read_csv_file(): Safely read CSV files
  • extract_download_speeds(): Filter 10MB download entries
  • bps_to_mbps(): Convert speed units
  • analyze_single_file(): Complete analysis of one file
  • analyze_multiple_files(): Batch processing
  • display_results(): Formatted output

analyze_all_files.py

Batch processing script that:

  • Finds all CSV files in the test_speed_data directory
  • Analyzes each file using the SpeedAnalyzer class
  • Displays comprehensive results for all files

example_usage.py

Demonstration script showing:

  • Single file analysis
  • Multiple file analysis
  • Custom analysis with additional statistics

Configuration

You can modify the target directory by changing the SPEED_TESTING_DIR constant in each script:

SPEED_TESTING_DIR = "test_speed_data"  # Change this to your directory

Requirements

  • Python 3.6+
  • Standard Library Only: csv, os, pathlib, glob, typing

Error Handling

The analyzer gracefully handles:

  • Missing or non-existent files
  • Invalid CSV data
  • Files without 10MB download entries
  • Corrupted or incomplete data rows

Contributing

  1. Fork the repository
  2. Create a 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

This project is open source and available under the MIT License.

Example Results

Here's what you can expect when analyzing different proxy providers' speed test results:

File: Webshare - Data Center Proxies
==================================================
Number of 10MB download tests: 6
Download speeds (Mbps):
  Test 1: 45.87 Mbps
  Test 2: 173.99 Mbps
  Test 3: 167.33 Mbps
  Test 4: 152.27 Mbps
  Test 5: 134.71 Mbps
  Test 6: 134.68 Mbps

Average speed: 134.81 Mbps

Support

If you encounter any issues or have questions:

  1. Check the existing issues in the repository
  2. Create a new issue with detailed information about your problem
  3. Include sample CSV data (anonymized) if relevant

Happy analyzing! 🚀

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages