I wrote a little c++-prog (for WinXP), that writes random data to my harddisk. I used ofstream, but the resulting transferrate is not what I expected (it´s too slow).
1 2 3 4 5
ofstream outfile( filename, ofstream::binary );
for( int h = 0; h < blockcount; h++ ){
outfile.write( buffer, BLOCKSIZE );
}
outfile.close();
Is there a faster way of writing large amounts of data? Is there some kind of "low level access" to IDE-disks? Is there a "ATA command programming guide"?
This belongs in General C++ Programming, but anyway: write() is actually pretty darn fast. You probably just made BLOCKSIZE too small. How large is it? 5 MB should give a decent rate, but of course, the bigger the block size, the more data can be transferred in a single loop cycle and function call, and the less overhead from these structures.
What?! Just how much data were you moving?
If you're just copying large amounts of data, don't load it to memory. You're just adding a middle man to the equation (disk->RAM->disk instead of disk->disk), which is why you'll never get 100% performance.
Let's see... I'm sure there must be some OS function for this...
Ah, here we go. CopyFile(): http://msdn.microsoft.com/en-us/library/aa363851(VS.85).aspx