Skip to content

Instantly share code, notes, and snippets.

@peterbe
Last active December 2, 2018 23:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterbe/af51fde2a7ed2c2bdf0a3e5b0d6e3e5b to your computer and use it in GitHub Desktop.
Save peterbe/af51fde2a7ed2c2bdf0a3e5b0d6e3e5b to your computer and use it in GitHub Desktop.
102650_300x300.jpg
105101_300x300.jpg
105819_300x300.jpg
106854_300x300.jpg
108064_300x300.jpg
109025_300x300.jpg
10951_300x300.jpg
109964_300x300.jpg
111227_300x300.jpg
111676_300x300.jpg
112043_300x300.jpg
11221_300x300.jpg
117051_300x300.jpg
118759_300x300.jpg
121315_300x300.jpg
127933_300x300.jpg
128191_300x300.jpg
1282_300x300.jpg
129233_300x300.jpg
130507_300x300.jpg
131604_300x300.jpg
13539_300x300.jpg
135923_300x300.jpg
138155_300x300.jpg
139244_300x300.jpg
139864_300x300.jpg
140465_300x300.jpg
143483_300x300.jpg
144380_300x300.jpg
144784_300x300.jpg
145106_300x300.jpg
145604_300x300.jpg
148145_300x300.jpg
149452_300x300.jpg
149595_300x300.jpg
151289_300x300.jpg
152032_300x300.jpg
153984_300x300.jpg
15463_300x300.jpg
155556_300x300.jpg
156771_300x300.jpg
1583_300x300.jpg
158918_300x300.jpg
163185_300x300.jpg
163569_300x300.jpg
164404_300x300.jpg
165171_300x300.jpg
167893_300x300.jpg
169434_300x300.jpg
169515_300x300.jpg
170571_300x300.jpg
170630_300x300.jpg
170763_300x300.jpg
171011_300x300.jpg
172008_300x300.jpg
172272_300x300.jpg
17312_300x300.jpg
175127_300x300.jpg
175909_300x300.jpg
179119_300x300.jpg
180592_300x300.jpg
181053_300x300.jpg
183495_300x300.jpg
18614_300x300.jpg
187254_300x300.jpg
188134_300x300.jpg
188201_300x300.jpg
191496_300x300.jpg
191666_300x300.jpg
19242_300x300.jpg
193766_300x300.jpg
194123_300x300.jpg
201751_300x300.jpg
203968_300x300.jpg
207963_300x300.jpg
208005_300x300.jpg
208622_300x300.jpg
210096_300x300.jpg
211135_300x300.jpg
212218_300x300.jpg
213696_300x300.jpg
215447_300x300.jpg
21563_300x300.jpg
216408_300x300.jpg
221871_300x300.jpg
225720_300x300.jpg
225828_300x300.jpg
228546_300x300.jpg
230876_300x300.jpg
231098_300x300.jpg
235585_300x300.jpg
238068_300x300.jpg
238589_300x300.jpg
242471_300x300.jpg
246111_300x300.jpg
247470_300x300.jpg
248681_300x300.jpg
250388_300x300.jpg
251217_300x300.jpg
251221_300x300.jpg
251588_300x300.jpg
252450_300x300.jpg
255198_300x300.jpg
25837_300x300.jpg
264036_300x300.jpg
268489_300x300.jpg
26962_300x300.jpg
270124_300x300.jpg
276189_300x300.jpg
27890_300x300.jpg
279111_300x300.jpg
28019_300x300.jpg
280577_300x300.jpg
281161_300x300.jpg
28116_300x300.jpg
284778_300x300.jpg
284922_300x300.jpg
287498_300x300.jpg
29882_300x300.jpg
322959_300x300.jpg
323256_300x300.jpg
331210_300x300.jpg
335717_300x300.jpg
338066_300x300.jpg
356737_300x300.jpg
359843_300x300.jpg
36240_300x300.jpg
38856_300x300.jpg
393268_300x300.jpg
393584_300x300.jpg
399099_300x300.jpg
402804_300x300.jpg
404686_300x300.jpg
407914_300x300.jpg
41074_300x300.jpg
411690_300x300.jpg
415125_300x300.jpg
42076_300x300.jpg
427479_300x300.jpg
430879_300x300.jpg
431738_300x300.jpg
433539_300x300.jpg
44072_300x300.jpg
44745_300x300.jpg
450736_300x300.jpg
450824_300x300.jpg
45153_300x300.jpg
45598_300x300.jpg
45607_300x300.jpg
45801_300x300.jpg
46138_300x300.jpg
471378_300x300.jpg
476149_300x300.jpg
47706_300x300.jpg
47775_300x300.jpg
485512_300x300.jpg
489627_300x300.jpg
494475_300x300.jpg
495164_300x300.jpg
496375_300x300.jpg
497545_300x300.jpg
499247_300x300.jpg
499889_300x300.jpg
50375_300x300.jpg
51221_300x300.jpg
52071_300x300.jpg
52502_300x300.jpg
52535_300x300.jpg
535535_300x300.jpg
54370_300x300.jpg
544121_300x300.jpg
5447_300x300.jpg
551373_300x300.jpg
558843_300x300.jpg
569924_300x300.jpg
572033_300x300.jpg
5735_300x300.jpg
57979_300x300.jpg
580719_300x300.jpg
583134_300x300.jpg
585864_300x300.jpg
586847_300x300.jpg
588417_300x300.jpg
588496_300x300.jpg
589104_300x300.jpg
589127_300x300.jpg
589754_300x300.jpg
589836_300x300.jpg
594254_300x300.jpg
59613_300x300.jpg
596644_300x300.jpg
597869_300x300.jpg
599759_300x300.jpg
59979_300x300.jpg
601483_300x300.jpg
601593_300x300.jpg
606775_300x300.jpg
608848_300x300.jpg
610160_300x300.jpg
613331_300x300.jpg
614490_300x300.jpg
616733_300x300.jpg
617154_300x300.jpg
619275_300x300.jpg
619531_300x300.jpg
620114_300x300.jpg
627980_300x300.jpg
629681_300x300.jpg
629740_300x300.jpg
630092_300x300.jpg
632586_300x300.jpg
636831_300x300.jpg
637408_300x300.jpg
637783_300x300.jpg
637818_300x300.jpg
639620_300x300.jpg
639879_300x300.jpg
640683_300x300.jpg
648854_300x300.jpg
65456_300x300.jpg
656960_300x300.jpg
657099_300x300.jpg
658119_300x300.jpg
658478_300x300.jpg
658644_300x300.jpg
660454_300x300.jpg
660708_300x300.jpg
662764_300x300.jpg
664428_300x300.jpg
665697_300x300.jpg
66676_300x300.jpg
673742_300x300.jpg
676293_300x300.jpg
680009_300x300.jpg
681580_300x300.jpg
684374_300x300.jpg
68467_300x300.jpg
684806_300x300.jpg
685320_300x300.jpg
688502_300x300.jpg
689608_300x300.jpg
693029_300x300.jpg
694704_300x300.jpg
696244_300x300.jpg
698597_300x300.jpg
70159_300x300.jpg
706945_300x300.jpg
708256_300x300.jpg
710113_300x300.jpg
710652_300x300.jpg
71072_300x300.jpg
71309_300x300.jpg
715435_300x300.jpg
71560_300x300.jpg
715918_300x300.jpg
72677_300x300.jpg
73527_300x300.jpg
736539_300x300.jpg
74087_300x300.jpg
75124_300x300.jpg
7680_300x300.jpg
78371_300x300.jpg
81234_300x300.jpg
815_300x300.jpg
8404_300x300.jpg
86254_300x300.jpg
86310_300x300.jpg
87142_300x300.jpg
88744_300x300.jpg
90414_300x300.jpg
91293_300x300.jpg
91763_300x300.jpg
91792_300x300.jpg
9313_300x300.jpg
93707_300x300.jpg
93861_300x300.jpg
94740_300x300.jpg
95718_300x300.jpg
97168_300x300.jpg
9805_300x300.jpg
98694_300x300.jpg
99520_300x300.jpg
guetzlied.json
mozjpeged.json
import csv
import time
import random
import statistics
from collections import defaultdict
from urllib.parse import urlparse
import requests
images = []
with open("images.txt") as c:
for line in c:
if line.strip().endswith(".jpg"):
images.append(line.strip())
base1 = "https://songsearch-2916.kxcdn.com/static/albums/2017/05/24/08/"
base2 = (
"https://songsearch.nyc3.cdn.digitaloceanspaces.com/images/albums/2017/05/24/08/"
)
def fmt(s):
return "{:.3f}s".format(s).ljust(10)
def print_stats(numbers):
print("DOMAIN".ljust(50), "MEDIAN".ljust(10), "MEAN")
for domain, times in numbers.items():
print(
domain.ljust(50), fmt(statistics.median(times)), fmt(statistics.mean(times))
)
length = len(times)
print(format(length, ","), "iterations.")
print("\n")
def run(*args):
seconds = int(args[0])
numbers = defaultdict(list)
try:
with open("./results.csv") as f:
reader = csv.reader(f)
for row in reader:
domain, took, status = row
took = float(took)
status = int(status)
if status == 200:
numbers[domain].append(took)
else:
print("STATUS CODE", domain, r.status_code)
print_stats(numbers)
except FileNotFoundError:
pass
try:
while True:
image = random.choice(images)
urls = [base1 + image, base2 + image]
random.shuffle(urls)
for url in urls:
t0 = time.time()
r = requests.get(url)
t1 = time.time()
domain = urlparse(url).netloc
res = "{}{:.4f}\t{}".format(domain.ljust(50), t1 - t0, r.status_code)
print(res)
with open("./results.csv", "a") as f:
writer = csv.writer(f)
writer.writerow([domain, t1 - t0, r.status_code])
if r.status_code == 200:
numbers[domain].append(t1 - t0)
else:
print("STATUS CODE", domain, r.status_code)
print()
time.sleep(seconds)
except KeyboardInterrupt:
print()
print_stats(numbers)
if __name__ == "__main__":
import sys
sys.exit(run(*sys.argv[1:]))
@peterbe
Copy link
Author

peterbe commented Oct 1, 2018

To run:

  1. Download both of these files.
  2. Get a Python3 environment that has requests installed.
  3. Type: python run.py 10
  4. Wait a very looong time.
  5. Ctrl-C

Look at the output and expect to see something like this:

DOMAIN                                             MEDIAN     MEAN
songsearch-2916.kxcdn.com                          0.XXXs     0.XXXs
songsearch.nyc3.cdn.digitaloceanspaces.com         0.XXXs     0.XXXs
123 iterations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment