Skip to content

Instantly share code, notes, and snippets.

@vignesh-m
Last active March 21, 2017 09:37
Show Gist options
  • Save vignesh-m/85db3c64231511f564812b6020cacb98 to your computer and use it in GitHub Desktop.
Save vignesh-m/85db3c64231511f564812b6020cacb98 to your computer and use it in GitHub Desktop.
networks lab wget
import os
import re
def stats(url):
os.system('wget ' + url + ' -o logfile')
s = open('logfile', 'r').read()
def speed(s):
a = re.findall('\(.*/s\)', s)
def mb2kb(s):
if s[-4] == 'K':
return float(s[:-5])
else:
return 1024 * float(s[:-5])
return mb2kb(a[0][1:-1])
def time(s):
a = re.findall('=.*s', s)
return float(a[0][1:-1])
return speed(s), time(s)
print(stats('localhost:8000/512kb'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment