Skip to content

Instantly share code, notes, and snippets.

@zielmicha
Created December 3, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zielmicha/c4ac8974d2f6a55bf548 to your computer and use it in GitHub Desktop.
Save zielmicha/c4ac8974d2f6a55bf548 to your computer and use it in GitHub Desktop.
import random, time
f = open('/dev/sda', 'rb')
L = 1000 ** 4 * 2
bs = 4096
while bs <= 1024 * 1024 * 128:
count = 0
start = time.time()
while time.time() - start < 30:
f.seek(random.randrange(0, L, bs), 0)
f.read(bs)
count += 1
took = time.time() - start
size = bs * count
print 'bs=%dk' % (bs / 1024), 'read=%d' % count, 'size=%.1f MB' % (size / 1024**2), 'speed=%.1f MB/s' % (size / took / 1024**2)
bs *= 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment