|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Committing Byte Array to DiskWhat is the fastest way of writing a Byte array to disk? I have a 512
MB array in memory. I am writing to a 10K RPM drive, and have ample CPU and RAM. I need to write as much data as possible, as fast as possible. Currently, I am using the StreamWriter. I am not getting anywhere near the thru put I would expect. My code is something like: For i = 0 To (MB.Length - 1) StreamWriter.Write(MB(i)) StreamWriter.Flush() Next Any recommendations on squeezing more performance? J Wolfgang Goerlich suggest you move the StreamWriter.Flush outside the loop
Show quoteHide quote "jwgoerl***@gmail.com" wrote: > What is the fastest way of writing a Byte array to disk? I have a 512 > MB array in memory. I am writing to a 10K RPM drive, and have ample CPU > and RAM. I need to write as much data as possible, as fast as possible. > > > Currently, I am using the StreamWriter. I am not getting anywhere near > the thru put I would expect. My code is something like: > > For i = 0 To (MB.Length - 1) > StreamWriter.Write(MB(i)) > StreamWriter.Flush() > Next > > Any recommendations on squeezing more performance? > > J Wolfgang Goerlich > > Use BinaryWriter instead.
bw.write(MB) Show quoteHide quote "guy" <g**@discussions.microsoft.com> wrote in message news:2D04CF28-BE5C-462F-B389-68133E2515BF@microsoft.com... > suggest you move the StreamWriter.Flush outside the loop > > "jwgoerl***@gmail.com" wrote: > >> What is the fastest way of writing a Byte array to disk? I have a 512 >> MB array in memory. I am writing to a 10K RPM drive, and have ample CPU >> and RAM. I need to write as much data as possible, as fast as possible. >> >> >> Currently, I am using the StreamWriter. I am not getting anywhere near >> the thru put I would expect. My code is something like: >> >> For i = 0 To (MB.Length - 1) >> StreamWriter.Write(MB(i)) >> StreamWriter.Flush() >> Next >> >> Any recommendations on squeezing more performance? >> >> J Wolfgang Goerlich >> >> Try writing the whole array at one time.
I am not sure if it is faster but it works for me. Public StatusData(255) As Byte To Save: Dim fnum As Integer = FreeFile() FileOpen(fnum, Application.StartupPath & "\Status.dat", OpenMode.Binary) FilePut(fnum, StatusData) FileClose(fnum) To Open: Dim fnum As Integer = FreeFile() FileOpen(fnum, Application.StartupPath & "\Status.dat", OpenMode.Binary) FileGet(fnum, StatusData) FileClose(fnum) > Close all other programs which have disk access.> > Currently, I am using the StreamWriter. I am not getting anywhere near > the thru put I would expect. My code is something like: > > For i = 0 To (MB.Length - 1) > StreamWriter.Write(MB(i)) > StreamWriter.Flush() > Next > > Any recommendations on squeezing more performance? > Cor Much obliged for all the help! I am getting closer. StreamWriter takes
around 60 minutes. FilePut takes about two minutes (and really uses the CPU!). BinaryWriter takes from 30-60 seconds. This is quite a performance boost. Yet, even at 30-seconds or 136 Mb/s, I am getting around half the thru put from the disks that I expected. I suspect it is time to dig into this from a hardware perspective. Thanks again, J Wolfgang Goerlich
How to update data in Windows Datagrid
ot: mvps, how do you propse one? DoEvents in VB.NET AddressOf from VB6 to .Net VB drag / drop list view items from two list views How to pass an object between forms. MouseUp event fires randomly on Listview Create a new dataset from a dataview Dirty value of datagridview cell How to pass an object between forms. |
|||||||||||||||||||||||