I am doing Wave data processing and reading them from disk to an array of bytes. I want to quickly copy parts from this byte array to another buffer for intermediate processing. I am currently using something like this:
float[] fin; byte[] buf; //fill buf code omitted for(int i=offset; i < size; i++){ fin[i-offset] = (float) buf[i]; }
I feel that this is a slow method, because in a for loop and as much computation takes place as much as in the actual body. If there is any copy of the block in C #, or I can implement a block copy, that would be great.
It may not be too slow, but it seems to work very hard to move some data. Here the "size" is between 2 ^ 10 and 2 ^ 14. Then I pass the fin to the FFT library, so this is not the slowest part of the code, maybe I bark the wrong tree.
EDIT UPDATE: I understand that micro optimization is not where someone should spend their time, and I understand that profiling is the best way to achieve acceleration in general, but I know that this code is in a “hot way” and should be less than a third full of second-to-one end-user architectures to minimize our system requirements. Although I know that the following FFT code will be much more time consuming, I am looking for accelerations where I can get them.
Array.Copy sure looks good, I did not know about it before, and I believe that this Q & A is already successful!
source share