def humanize_bytes(bytes, precision=1): | |
# taken from http://code.activestate.com/recipes/577081-humanized-representation-of-a-number-of-bytes/ | |
abbrevs = ( | |
(1<<60L, 'EB'), | |
(1<<50L, 'PB'), | |
(1<<40L, 'TB'), | |
(1<<30L, 'GB'), | |
(1<<20L, 'MB'), | |
(1<<10L, 'kB'), | |
(1, 'bytes') | |
) | |
if bytes == 1: | |
return '1 byte' | |
for factor, suffix in abbrevs: | |
if bytes >= factor: | |
break | |
return '%.*f %s' % (precision, bytes / factor, suffix) | |
age = 60 | |
lifetime = age*365*24*60*60 # seconds we've been alive | |
rods = 120E6 | |
cones = 7E6 | |
eyeCells = rods+cones | |
eyeRefresh = 1/30 # 30 Hz | |
eyeDataRate = 10E6 # bits / second | |
eyesDataRate = eyeDataRate * 2 # we have two eyes | |
eyesDataRateBytes = eyesDataRate/8. # bits to bytes | |
humanizedEyes = humanize_bytes(eyesDataRateBytes) | |
print 'Eyes data rate is %s per second.' %humanizedEyes | |
earRate = 22E3 # 22 Khz is the maximum the ear can hear | |
earRate *= 2 # multiply by two to avoid sampling errors | |
earSensitivity = 2**16 | |
earDataRate = earRate * earSensitivity # sampling rate * bits = data rate (bits/second) | |
earsDataRate = earDataRate * 2 # we have two ears | |
earsDataRateBytes = earsDataRate / 8. | |
humanizedEars = humanize_bytes(earsDataRateBytes) | |
print 'Ears data rate is %s per second.' %humanizedEars | |
# Now we want to add these up over a lifetime. | |
eyeData = lifetime * eyesDataRateBytes | |
humanizedTotalEyes = humanize_bytes(eyeData) | |
print 'over %s years, our eyes will transmit %s' %(age, humanizedTotalEyes) | |
earData = lifetime * earsDataRateBytes | |
humanizedTotalEars = humanize_bytes(earData) | |
print 'over %s years, our ears will transmit %s' %(age, humanizedTotalEars) | |
totalData = earData+eyeData | |
humanizedTotal = humanize_bytes(totalData) | |
print 'The total information we will receive will be upwards of... ' | |
print '%s' %humanizedTotal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment