write large file to disk
| shag7 (3) | |||
| Hi, 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).
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"? Thanks in advance! Have a nice day Sebastian | |||
| helios (829) | |||
| 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. | |||
| shag7 (3) | |||
| yes, I hoped there are "special windows functions" to perform this task. Thats why i placed it here BLOCKSIZE was 10MB but transfer rate was ~ 0.3*MAXTRANSFERRATE and CPU usage was at 100%! (MAXTRANSFERRATE = max hdd transferrate measured with h2benchw) h2benchw writes to disks containing no partitions. I think I have to find out how this is done. Any hints? ;-) greets and thanks Sebastian | |||
| helios (829) | |||
| 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 | |||
| shag7 (3) | |||
Thanks a lot! WriteFile and CopyFile were the functions I was looking for. | |||
This topic is archived - New replies not allowed.
