During last blog post I said that the CRC calculation is quite slow…
That’s true, so I did some change of data structures and program flow to improve the situation. I used the following configuration:
300 Messages, sweeping from 1 bit to 300 bits. That results to 90.000 messages.
Starting with BitArray: 5.8 seconds
Moving from BitArray to List<bool>: 4.4 seconds, getting better
Moving from List<bool> to bool[]: 4.4 seconds, same
Using Parallel.Foreach: 1.4 seconds, Yeah!
Before, I used Parallel.Foreach for the calculation of the messages itself, but this caused some synchronization overhead because the results of each calculations, which only lasts some milliseconds will prevent using the multicore processor efficiently.
Just using Parallels at the right place, increases speed by 300% on a 4 core i5.
But, to be honest:
1.4 seconds are still too much for about 90.000 messages. So additional work is necessary!