This is a PLC program so the values can change without knowledge. can someone think of a hash algo that will check if 5 to 10 integers have changed since last cycle. I need this to be as fast as possible.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why not just check them against a copy of the previous set of values?
The effort to simply check all 10 is linear, small and constant. It is unlikely that a hash function would be faster (you can’t avoid reading the values, and that’s pretty much all the work required to do a compare), and even it were, having the same hash code doesn’t tell you the values haven’t changed, so you still have to compare all 10 sometimes.
If getting the answer wrong occasionally is OK, you could just XOR all ten values (assumed to be modest size binary integers) for a hashcode, and check against that. That would avoid reading the old/new values, cutting the read count in half. Given all the other work the PLC is doing, I doubt if this savings is anything other than nanoscopic.