Files @ b052f27e1cbc
Branch filter:

Location: Morevna/src/benchmark.py

Laman
more progress info
from time import time

from hashtree import HashTree


def timeF(f):
	start=time()
	f()
	end=time()
	print((end-start),"s")


def fullRead():
	block=True
	with open("/home/laman/ext2.img",mode="rb") as f:
		while block:
			block=f.read(HashTree.BLOCK_SIZE)


def selectedRead():
	with open("/home/laman/blocks.txt") as f:
		blocks=[int(x) for x in f]
	with open("/home/laman/ext2.img",mode="rb") as f:
		i1=-1
		for i2 in blocks:
			if i1+1!=i2:
				f.seek(i2*HashTree.BLOCK_SIZE)
			block=f.read(HashTree.BLOCK_SIZE)
			i1=i2


def lessSelectedRead():
	with open("/home/laman/blocks.txt") as f:
		blocks=[int(x) for x in f]
	with open("/home/laman/ext2.img",mode="rb") as f:
		i1=-1
		for i2 in blocks:
			if i2<=i1+8:
				block=f.read(HashTree.BLOCK_SIZE*(i2-i1))
			else:
				f.seek(i2*HashTree.BLOCK_SIZE)
				block=f.read(HashTree.BLOCK_SIZE)
			i1=i2


def shortSockets():
	pass


def longSockets():
	pass


# timeF(fullRead) # 85.40341448783875 s
# timeF(selectedRead) # 6.774365186691284 s
# timeF(lessSelectedRead) # 5.930811405181885 s