Nina Milo wrote:Thanks Henry. I appreciate your answer the code snippet i have wriiten has nothing do with endian processing. I am working on something else which does requires the conversion from big endian to little endian and vice versa.
I wanted to know the I/O performance in general. Which is faster in reading/writing among Ascii and binary files?
In general, I/O is slower than the CPU. This is a weird thing to say because these are two different things, and arguably, not even comparable. What is meant by this, is that when I/O is being done, the CPU is waiting for the data -- and the waiting is an order of magnitude slower... example, in the time to wait for the bytes, the CPU could have spent hundreds, perhaps thousands of cycles, on each byte (if it didn't have to wait).
So... yes, doing a bit order flip to each byte does take more time (one or two cycles via a lookup table). However, you'll probably not even notice it, if you take into the account the time to fetch the bytes from the file too.
Henry