Skip to content

Instantly share code, notes, and snippets.

Created December 15, 2020 10:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#!/usr/bin/env python
import os
import sys
import random
import time
PATH = "/mnt/gdrive/large_random_file"
CHUNK_SIZE = 16*1024
fh =, os.O_RDONLY)
size = os.path.getsize(PATH)
readData = b''
start = time.time()
for _ in range(CHUNKS_READ_COUNT):
os.lseek(fh, random.randrange(size-CHUNK_SIZE), os.SEEK_SET)
readData +=, CHUNK_SIZE)
end = time.time()
execution = end - start
print("Finished. Took {} seconds. Average {} reads per second".format(execution, CHUNKS_READ_COUNT / execution))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment