Improving performance of for loop when decimating a buffer

后端 未结 3 1618
无人共我
无人共我 2021-01-28 07:13

I am collecting 16384 double values from a hardware device using a signal processing library. The 16384 values I receive are the output of a low pass filter. I want to down sa

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 07:24

    You could try putting each buffer into a dictionary and processing them in a for each. Theoretically this should be faster because the arrays will be processed in parallel. 20ms is pretty fast, why the need for such speed?

    var buffers = new Dictionary();
    

    Then process something like this:

    var myData = realbuffer.ToArray();
    
    buffers.Add(bufferCount, myData);
    
    if (bufferCount == 10)
    {
       Parallel.ForEach(buffers, (buffer) =>
       {
          //process buffer independently
       });
    }
    

提交回复
热议问题