Skip to content

Instantly share code, notes, and snippets.

@fxsjy
Created July 22, 2012 07:45
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 fxsjy/3158805 to your computer and use it in GitHub Desktop.
Save fxsjy/3158805 to your computer and use it in GitHub Desktop.
python random read disk
import random
import time
size=100000000
t1 = time.time()
f=open('x.db','wb')
f.write('x'*size)
f.close()
print 'write:', time.time()-t1
f=open('x.db','rb')
t2=time.time()
for i in xrange(10000):
pos=int(random.random()*size)
f.seek(pos)
f.read(1)
print 'random read:',time.time()-t2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment