I am trying to implement a character-frequency function in C. This task is very simple of course, simply loop over the string and increment like this:
for(cycle = 0; cycle < length; cycle++){
integer = line[cycle];
bins[ integer*length+cycle ]++;
}
Now when doing this over a billion times or more (yes my files are that big), this part of the program becomes pretty time intensive as the array will have to be accessed 10e8 * length times.
I googled around for some time now and have found ample examples how to add, multiply, divide, etc with the use of registers, but as I am not the slightest familiar with SSE, MMX, etc. I have no idea how to implement character counting using these functions.
I am hoping to reduce the time spent in this function as 4 characters could be read simultaneously. Could you please show me in the right direction or even better present a piece of code?
Thanks in advance. Mark