>
>Hi,
>Don't know why the speed difference but have you tried pre-setting the capacity of list using the Capacity property (in both scenarios)?
>Best,
>Viv
Just did, Viv
There is no difference, and I would not have expected one since there are 6000000 iterations and the list must be expanded to its capacity after the first iteration
I was quite surprised to find that out
[Context]
I'm playing with streams, subclassed the stream to implement a base64 encoder/decoder
The problem with ToBase64Transform and FromBase64Transform is that you have to buffer the input, transform (pieces of )the input [ you do not know in advance whether to call TransformBlock or TransformFinalBlock ], and put the transformations on an outputbuffer
protected Queue<Byte> InBuffer = new Queue<byte>();
protected Queue<Byte> OutBuffer = new Queue<byte>();
The Read and Write of the stream work with arrays
So I tried - just for fun - how it would perform if I were to use List(byte)
I started testing with different array sizes - and found out that the List() is actually quite fast compared to the Queue
[ and the list is slower with many items compared to the queue ]
Gregory