binary file not reading any faster on SSD than on HD

2 views (last 30 days)
I wanted to test the speedup using an SSD to store large files for read/write in MATLAB as compared to a standard HD. I placed a copy of the same 2.8GB binary data file (a raster DEM in this case) on both drives and executed the following function, inputting the appropriate data file:
%------------------------------
function scan_test(fnam,rows,cols)
%------------------------------
% fnam = path & filename of a 2.8GB binary DEM file in BIL format
% (main BIL file is pure data, with the header in a separate file)
% rows = number of rows = 29051
% cols = number of columns = 25032
sc = 100;
% sc = number of rows to read with each loop iteration
% (vary this parameter to test different read "chunk" sizes)
dv = floor(rows/sc);
fid = fopen(fnam,'rb','b'); % byte order is Big Endian, so use 'b' option
tic
for j = 1:dv
dat = fread(fid,cols*sc,'single');
end;
toc
fclose(fid);
%------------------------------
Regardless of what value I use for 'sc' above (tried 1, 100, 1000, etc.), I observe almost identical performance between the SSD and HD, with the HD file actually being read in ~4-5% less time in each case (e.g., with sc = 100 as above, the runs took 6.471s and 6.154s on SSD and HD, respectively). And yes, I realize I am not reading all the way until the end of the file [mod(rows*cols,sc) lines will remain], but that is not important.
My question: Why do I not see a speed up reading from the SSD compared to the HD?
Computer: 6-core I7 chipset running Windows 7, using MATLAB R14a. In case it matters, my SSD is my C drive, where the OS and MATLAB are installed.
Thanks in advance for any insight you can provide. If you need more information, let me know.

Answers (1)

Image Analyst
Image Analyst on 9 Jan 2015
I think it's because you're reading all that data from the same file. The file was read once and put in the cache and then all the rest of the reads are coming from RAM memory, which is where your disk cache is, not from the disks. See http://en.wikipedia.org/wiki/Cache_%28computing%29. Try reading different files so you're not getting cached data. It's reading different files where the speed difference will show up, not reading data from the same file (which cached a huge chunk of the file after the first read from it).
For me, to compile a program went from about 4 minutes on a HDD to about 30 seconds on a SSD.
  1 Comment
Jude Kastens
Jude Kastens on 9 Jan 2015
Thanks for the insight. Seems like a logical explanation that the data are being cached to some degree in the computer's 16GB of RAM. I will test your hypothesis and post a follow-up message.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!