I'm getting some slow performance when reading and writing large byte arrays using ES2. I notice in the code that ES2 seems to write and read/parse one byte at the time using a loop. Clearly, since System.IO.File.ReadAllBytes is much, much faster, ES2 should be able to read and write byte arrays very fast, too.
Is there any best practices for this? Currently, I've been using ReadArray<byte> and WriteArray<byte>, but maybe there's a better way for byte arrays?
Thank you.
All the best and Merry Xmas!
Best practices for reading and writing byte arrays
-
- Posts: 22
- Joined: Thu Nov 13, 2014 9:05 pm
Re: Best practices for reading and writing byte arrays
Hi there,
You should use ES2.SaveRaw and ES2.LoadRaw if you want to write bytes directly to a file.
All the best,
Joel
You should use ES2.SaveRaw and ES2.LoadRaw if you want to write bytes directly to a file.
All the best,
Joel
-
- Posts: 22
- Joined: Thu Nov 13, 2014 9:05 pm
Re: Best practices for reading and writing byte arrays
I need this to be part of a ES2Writer and have it retrievable by ES2Data. Is it not possible to WriteRaw with tag?
-
- Posts: 22
- Joined: Thu Nov 13, 2014 9:05 pm
Re: Best practices for reading and writing byte arrays
I suppose one could create a custom ES2Type wrapper class for byte[] that uses writer.WriteRaw for the byte array. Then you would be able to save byte arrays fast and with tag support.
-
- Posts: 22
- Joined: Thu Nov 13, 2014 9:05 pm
Re: Best practices for reading and writing byte arrays
I added a custom wrapper type and some extension methods, so now I can save byte arrays fast with ES2Writer.SaveBytes and ES2Data.LoadBytes. Speedup is around 10x.
All the best.
Happy new year in advance!
All the best.
Happy new year in advance!
Re: Best practices for reading and writing byte arrays
This is what I would have suggested, so glad you came across this before the Christmas break got in the wayMaximumFirecracker wrote:I added a custom wrapper type and some extension methods, so now I can save byte arrays fast with ES2Writer.SaveBytes and ES2Data.LoadBytes. Speedup is around 10x.
All the best.
Happy new year in advance!
Happy new year in advance to yourself also!
All the best,
Joel