2008-12-16, 18:10
Hi!
I want to know how you count the spead of a file in Python?
How to get the rate only in seconds? it gives me diffrents rate when i change the sizeOfFile. pleas help me, i am new in python.
//Sofi
I want to know how you count the spead of a file in Python?
Code:
import time
# Declartiona of varibles
expectedRate = 60
text = 10 * "dfdkfdfkdfkdfkdkfkdfkkdfkdkfjkdfkkdj3904892389489238498293843809280948903289048203984092809854820984" # =1000 byte= 1kbyte
f_dir = 'V:/Python_ex/fFile.txt'
f_mod = 'w'
sizeOfFile = 100
f = open(f_dir, f_mod) # create a new file
for i in range(0, sizeOfFile): #Write the text 100 times
f.write(text)
f.close()
f_mod = 'r'
f = open(f_dir, f_mod) #
TimeStart = time.time()
f.read()
TimeEnd = time.time()
difr = TimeEnd - TimeStart
rate = sizeOfFile/difr
print difr
print rate
if expectedRate < rate:
print "error"
else:
print "Pass"
How to get the rate only in seconds? it gives me diffrents rate when i change the sizeOfFile. pleas help me, i am new in python.
//Sofi