USB Test Program
Author: Kyle O'Brien
The goal of the test program is assess the performance of USB flash drives through various series of reads, writes, opens, and closes of the files. The arguments to the code allow one to specifically manipulate various parameters.
Special Notes
- Currently, there is still no way to bypass the read cache.
Results File:
Once usbtest has been run it will append the results to the file results.csv (comma separated values). It is in the following format:
test,time in seconds,time in microseconds,block size,blocks to write,tests to run,files to use,read/writes per cycle,hostname,start timestamp,comments
Syntax:
./usbtest -x value -y value
-t test
- w (write test)
- r (read test)
- m (multiple file test)
- s (seek/read test)
- X (use this when you do not want a test to be run)
-b blockSize (specifies the size of blocks to be read/written, value in bytes)
-x blocksToWrite (specifies how many blocks to write to the file)
-f filesToUse (specifies how many files should be used in multiple files test and read test)
-n testsToRun (specifies how many times to repeat the test)
-r readWritesPerCycle (will do
x writes before doing
x reads in multiple file test)
-l fileName (specifies the path and filename of the testfile(s), example: /mnt/usb1/testfile)
-c comments (comments to be stored in results file)
Tests
Below is the basic functionality of each test between the "start" and "stop" time readings.
Write Test
- For loop from 0 to testsToRun
- For loop from 0 to filesToUse (i is variable used)
- If filesToUse is NOT 1 set filesToOpen = fileName & i
- Open file
- If blockSize is 0 then let OS buffer data, else no buffering
- For loop from 0 to blocksToWrite
- Write one block of data
- If blockSize is 0 then use fsync to wait until all data is written
- Close file
Read Test
- For loop from 0 to testsToRun*filesToUse
- If filesToUse is NOT 1 set fileToOpen = fileName & (rand() % filesToUse)
- Open file
- For loop from 0 to blocksToRead (blocksToRead is automatically detected before start timestamp)
- Read one block of data
- Close file
Multiple File Test
- For loop from 0 to testsToRun
- Get 2 random numbers
- Open random file 1 for write, random file 2 for read
- For loop from 0 to blocksToWrite/readWritesPerCycle
- For loop from 0 to readWritesPerCycle
- Write one block of data to file 1
- For loop from 0 to readWritesPerCycle
- Read one block of data from file 2
- Close both files
Seek/Read Test
- Open file
- For loop from 0 to numberOfTests
- Read one block of data from random location using pread
- Close file