Files
@ 802cbad78f7d
Branch filter:
Location: Morevna/src/benchmark.py - annotation
802cbad78f7d
1.0 KiB
text/x-python
benchmarking
802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d 802cbad78f7d | 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
|