Its amazing to test usb drive speed with python, a small script in python can check the removable disk’s speed. Just run the code in python and you will get your Removable USB Flash Drive(Pen Drive) Speed. Here is how you can test pendrive speed with ptyhon.
Code provided in 2nd method can test speed of usb device on all operating systems.
How to test Pen Drive speed with Python
1st Method to Run Speed Test (windows only)
- Plug -in your USB drive to the computer
- Open Python 2.7
- Run the code
Python Code For Quick Speed Test (
import time, os
path = raw_input("Enter the Path Drive Letter of Removale Drive. e.g I ")
testFile = path+":/crazyTest"
print "Checking your Removable Drive Speed......"
f = open(testFile,'a')
for i in range(0,160000):
f.write('we are testing write speed')
diff = time.clock() - sTime
speed = (os.stat(testFile).st_size/1048576)/diff
print "your Removable. drive speed is "+ str(100/int(diff)) +"% near above "+str(speed)+" mb/sec"
startTime = time.clock()
The above code will generate a file in your USB file system. This code is estimating the speed of your usb drive by getting the time difference before it start writing the file and when it is finished.
2nd Method to Run Speed Test (All operating systems)
You can download the above code from github repository: usb-speed-test-python
- Run main.py file
- Type full and correct path
- Result would be an approx drive speed in mb/sec
Thanks for using the script !!