Skip to content

Instantly share code, notes, and snippets.

@padix-key
Created February 26, 2024 17:31
Show Gist options
  • Save padix-key/975751d0f5b22c56835d19c25df6fdf2 to your computer and use it in GitHub Desktop.
Save padix-key/975751d0f5b22c56835d19c25df6fdf2 to your computer and use it in GitHub Desktop.
Unzipped vs. zipped RCSB download
import requests
import gzip
import timeit
import numpy as np
PDB_ID = "4v6x"
def gzip_download():
r = requests.get(f"https://files.rcsb.org/download/{PDB_ID}.cif.gz")
content = gzip.decompress(r.content)
def download():
r = requests.get(f"https://files.rcsb.org/download/{PDB_ID}.cif")
content = r.content
num_runs = 1
num_repetions = 10
download_times = timeit.Timer(download).repeat(repeat=num_repetions, number=num_runs)
download_median = np.median(download_times) / num_runs
gzip_download_times = timeit.Timer(gzip_download).repeat(repeat=num_repetions, number=num_runs)
gzip_download_median = np.median(gzip_download_times) / num_runs
print(f'{download_median=}')
print(f'{gzip_download_median=}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment