Last active
March 7, 2023 01:20
-
-
Save pcuzner/215d1ee89bb96f07d9add291e388ecab to your computer and use it in GitHub Desktop.
Quick analysis of cloudping to identify regions that match a specific inter-region latency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
# data extracted from cloudping : https://www.cloudping.co/grid/p_90/timeframe/1D | |
rows = [] | |
try: | |
max_latency = int(sys.argv[1]) | |
except (IndexError, ValueError): | |
max_latency = 20 | |
print(f'\n- defaulting to {max_latency}ms\n') | |
with open('./cloud_ping_data.csv') as f: | |
raw = f.readlines() | |
header = raw[0] | |
rows = raw[1:] | |
locations = header.rstrip().replace('"', '').split(',')[1:] | |
compatible_regions = [] | |
region_set = set() | |
for row in rows: | |
data = row.rstrip().replace('"', '').split(',') | |
region = data[0] | |
samples = [float(sample) for sample in data[1:]] | |
for ptr in range(len(samples)): | |
if (samples[ptr] <= max_latency): | |
if (region == locations[ptr]): | |
continue | |
region_set.add(region) | |
compatible_regions.append(f'{region} to {locations[ptr]} : {samples[ptr]}ms') | |
if compatible_regions: | |
print(f'{len(compatible_regions)} compatible region combinations with {max_latency}ms or less latency:') | |
for region in compatible_regions: | |
print(f'\t- {region}') | |
print(f'\nUnique regions: {len(region_set)}') | |
for r in sorted(list(region_set)): | |
print(f'\t- {r}') | |
else: | |
print(f"no compatible regions found for {max_latency}ms latency") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment