|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
byte array size for read or write of filestreamwhat is the most performant size for the byte array for reading/writing using 2 filestreams? example code: Dim bytearrayinput(4095) As Byte Dim rdlen As Long = 0 Dim totlen As Long = fsInput.Length Dim len As Integer While (rdlen < totlen) len = fsInput.Read(bytearrayinput, 0, 4096) fsOutput.Write(bytearrayinput, 0, len) rdlen = rdlen + len End While Grtz. Hi,
Can you tell us why this is important, mostly the differences are so few that thinking about it is complete culprit because the device it is sent to makes the difference. By instance an ADSL line or a dialupline gives such a difference that optimizing in the program has no sense. But probably you have a reason. Cor Show quoteHide quote "news.microsoft.com" <Yves_no_spam@hotmail.com> schreef in bericht news:%23qQ7c0ycGHA.636@TK2MSFTNGP05.phx.gbl... > Hello, > > what is the most performant size for the byte array for reading/writing > using 2 filestreams? > > example code: > > Dim bytearrayinput(4095) As Byte > Dim rdlen As Long = 0 > Dim totlen As Long = fsInput.Length > Dim len As Integer > > While (rdlen < totlen) > len = fsInput.Read(bytearrayinput, 0, 4096) > fsOutput.Write(bytearrayinput, 0, len) > rdlen = rdlen + len > End While > > > Grtz. > > It's when writing large files to disc (movies)
Is it better to do one big read and then one big write or like below? Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uIqnQf0cGHA.380@TK2MSFTNGP04.phx.gbl... > Hi, > > Can you tell us why this is important, mostly the differences are so few > that thinking about it is complete culprit because the device it is sent to > makes the difference. By instance an ADSL line or a dialupline gives such a > difference that optimizing in the program has no sense. But probably you > have a reason. > > Cor > > "news.microsoft.com" <Yves_no_spam@hotmail.com> schreef in bericht > news:%23qQ7c0ycGHA.636@TK2MSFTNGP05.phx.gbl... > > Hello, > > > > what is the most performant size for the byte array for reading/writing > > using 2 filestreams? > > > > example code: > > > > Dim bytearrayinput(4095) As Byte > > Dim rdlen As Long = 0 > > Dim totlen As Long = fsInput.Length > > Dim len As Integer > > > > While (rdlen < totlen) > > len = fsInput.Read(bytearrayinput, 0, 4096) > > fsOutput.Write(bytearrayinput, 0, len) > > rdlen = rdlen + len > > End While > > > > > > Grtz. > > > > > > Hi,
I would not borrow to much about that. In general the guys did a good job at Microsoft with Net. If there is something that real does not perform, they have the kick to make it better. image save http://msdn2.microsoft.com/en-us/library/system.drawing.image.save.aspx Cor Show quoteHide quote "news.microsoft.com" <Yves_no_spam@hotmail.com> schreef in bericht news:ue%23cnP2cGHA.2068@TK2MSFTNGP02.phx.gbl... > It's when writing large files to disc (movies) > Is it better to do one big read and then one big write or like below? > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:uIqnQf0cGHA.380@TK2MSFTNGP04.phx.gbl... >> Hi, >> >> Can you tell us why this is important, mostly the differences are so few >> that thinking about it is complete culprit because the device it is sent > to >> makes the difference. By instance an ADSL line or a dialupline gives such > a >> difference that optimizing in the program has no sense. But probably you >> have a reason. >> >> Cor >> >> "news.microsoft.com" <Yves_no_spam@hotmail.com> schreef in bericht >> news:%23qQ7c0ycGHA.636@TK2MSFTNGP05.phx.gbl... >> > Hello, >> > >> > what is the most performant size for the byte array for reading/writing >> > using 2 filestreams? >> > >> > example code: >> > >> > Dim bytearrayinput(4095) As Byte >> > Dim rdlen As Long = 0 >> > Dim totlen As Long = fsInput.Length >> > Dim len As Integer >> > >> > While (rdlen < totlen) >> > len = fsInput.Read(bytearrayinput, 0, 4096) >> > fsOutput.Write(bytearrayinput, 0, len) >> > rdlen = rdlen + len >> > End While >> > >> > >> > Grtz. >> > >> > >> >> > > Grtz,
In addition to the other comments: | what is the most performant size for the byte array for reading/writing What is most performant for my machine is probably not most performant for | using 2 filestreams? Cor's machine, nor your machine. Any number of factors contribute to performance of reading & writing between 2 file streams, this includes but is not limited to: 1. Size & number of processors 2. Size, type & number of drive controllers (IDE, USB, SATA, ...) 3. Size, type & number of drives (hard drive, memory stick, floppy drive) 4. Amount of physical RAM 5. Amount of available virtual memory 6. Size of the files involved. 7. Size of the buffering internal to the filestream 8. Number of processes & threads currently executing (including type of program) Of course some of these factors more so then others. ;-) Generally what I do is pick a large enough number that doesn't feel too large. For example 32K or 64K, I might even consider 128K. If the performance didn't "feel" right, I would pick another number. I would also consider using Performance Monitor to see what the program is doing when running the application with files that are the expected average size. Conceptionally the program could be written to use performance counters to monitor how performant it was itself, and adjust itself accordingly... -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "news.microsoft.com" <Yves_no_spam@hotmail.com> wrote in message news:%23qQ7c0ycGHA.636@TK2MSFTNGP05.phx.gbl... | Hello, | | what is the most performant size for the byte array for reading/writing | using 2 filestreams? | | example code: | | Dim bytearrayinput(4095) As Byte | Dim rdlen As Long = 0 | Dim totlen As Long = fsInput.Length | Dim len As Integer | | While (rdlen < totlen) | len = fsInput.Read(bytearrayinput, 0, 4096) | fsOutput.Write(bytearrayinput, 0, len) | rdlen = rdlen + len | End While | | | Grtz. | | news.microsoft.com wrote:
> what is the most performant size for the byte array for See the "General I/O Tips" section of> reading/writing using 2 filestreams? http://msdn.microsoft.com/msdnmag/issues/06/01/CLRInsideOut/default.aspx Andrew
Date Errors in .NET 2.0
VB .NET very slow in design Dynamically adding a stylesheet control array question for VB.Net 2005 VB Form: Controlbox = False How do I embed a text file in my exe? Basic Database Questions Optional X as Boolean = ??? to detect missing argument? Standarddrucker mit .Net ermitteln Enter-key to have tab-key functionality |
|||||||||||||||||||||||