How to count file reading-spead in Python?
#1
Hi!

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
Reply
#2
if u use endtime - starttime you will end up with the seconds it took
Reply
#3
You're doing the math right you're just leaving out the fact that your script doesn't have exclusive control over hardware so the transfer speed won't be the same EVERY time.
Reply

Logout Mark Read Team Forum Stats Members Help
How to count file reading-spead in Python?0