-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Description
Have you considered a possible optimization by looping on the array 2 bytes at a time ? This can be done using pointers :
For example :
fixed (byte* dataPtr = data)
{
ushort* ushortPtr = (ushort*)dataPtr;
for (int i = 0 ; i < data.Length / 2; i++)
{
ushort value = *ushortPtr++;
}
}The idea would be to use the ushort directly. If you have to split it into two bytes (eg: using a byte shift or a struct with some clever packing) you probably lose the speed gain.
I don't know if a 16-bit 65536 entries lookup table could be used. Tradeoff is it might not fit in CPU cache.
I saw your implementation that deals with 16 bytes at a time. Maybe this could be done as well here. Like processing 8 bytes at a time but with ushorts.
Metadata
Metadata
Assignees
Labels
No labels