Optimizing Clash Proxy Selection Performance | Generated by AI

Home 2025.10

Summary of Optimization: Clash Proxy Selection Scripts

I optimized the Clash proxy selection scripts to avoid testing proxies that won’t be selected, significantly boosting performance by minimizing unnecessary speed tests.

What Was Optimized

The original code followed this inefficient workflow:

  1. Test all available proxies for speed.
  2. Then filter to select only SG/TW (or HK) proxies.
  3. This resulted in wasted time testing proxies that would be discarded.

The Fix

Modified the get_top_proxies() function in speed.py to accept a name_filter parameter and apply filtering before speed testing:

def get_top_proxies(num_results=5, name_filter=None):
    """
    Tests Clash proxy speeds concurrently and returns the top N fastest individual proxies.

    Args:
        num_results (int): Number of top proxies to return (default: 5)
        name_filter (list): List of strings to filter proxy names. Only proxies containing
                           any of these strings in their name will be tested.
    """

Performance Benefits

Simplified Configuration

Removed the --hk flag. The script now always tests only SG and TW proxies by default for maximum focus and simplicity.

Results

The optimization drastically reduced execution time, as most proxies do not contain “SG” or “TW” in their names. This makes the speed-testing phase far more efficient, delivering results faster without compromising functionality.


Back

x-ai/grok-code-fast-1

Donate