Skip to content

Instantly share code, notes, and snippets.

@Axadiw
Created Dec 15, 2020
Embed
What would you like to do?
#!/usr/bin/env python
import os
import sys
import random
import time
import filecmp
random.seed(1234)
PATHS = ["/mnt/gdrive/large_random_file",
"/mnt/gdrive2/large_random_file",
"/mnt/gdrive3/large_random_file"]
CHUNK_SIZE = 16*1024
CHUNKS_READ_COUNT = 400
fhs = []
counter = 0
for path in PATHS:
fhs.append(os.open(path, os.O_RDONLY))
counter = 0
size = os.path.getsize(PATHS[0])
readData = b''
start = time.time()
for _ in range(CHUNKS_READ_COUNT):
os.lseek(fhs[counter], random.randrange(size-CHUNK_SIZE), os.SEEK_SET)
readData += os.read(fhs[counter], CHUNK_SIZE)
counter += 1
counter %= len(PATHS)
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